RIght, the activity instance tracker depends on GC to decrement its value.

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/app/Activity.java#L732

https://github.com/android/platform_frameworks_base/blob/master/core/java/android/os/StrictMode.java#L2149

Using onDestroy/onCreate would let the count be more accurate during
orientation changes... but won't track memory leaks caused by Context
references, which probably is a more common issue.

-- K

2012/6/7 Daniel Drozdzewski <[email protected]>

> On 7 June 2012 15:06, Kostya Vasilyev <[email protected]> wrote:
> > I remember seeing this in one of my apps in certain cases.
> >
> > My conclusion was that this might be a bug in strict mode code, and
> disabled
> > it.
> >
> > Activity orientation changes are processed within a single message loop
> > heartbeat, so it's entirely possible that the lifecycles of both activity
> > instances overlap.
>
>
> +1
>
> Setting launchMode to 'singleInstance' can solve this 'issue', as it
> will force each (re)created activity to launch in a separate task.
> However the wider issue to consider is that
> StrictMode.ThreadPolicy.Builder.detectAll() detects *potential*
> problems.
>
> The fact that once GCed the activity dissapears, means that it will
> get eventually cleared and is not a leak.
>
>
> Daniel
>
>
> >
> > 2012/6/7 marcin kolonko <[email protected]>
> >>
> >> ok, i did some memory digging with ddms and memory analizer. and there'
> >> s weird behavior:
> >>
> >> when i run the garbage collector while in portrait mode (still the same
> >> case us in first post) and come back to portrait mode, nothing bad
> happens.
> >> the app behaves as it should.
> >> when i don't run the garbage collector, the app crashes with the
> instance
> >> count violation error.
> >
> >
> > --
> > You received this message because you are subscribed to the Google
> > Groups "Android Developers" group.
> > To post to this group, send email to [email protected]
> > To unsubscribe from this group, send email to
> > [email protected]
> > For more options, visit this group at
> > http://groups.google.com/group/android-developers?hl=en
>
>
>
> --
> Daniel Drozdzewski
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> To unsubscribe from this group, send email to
> [email protected]
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en
>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to