On Jul 7, 12:27 am, Romain Guy <[email protected]> wrote:
> There is no leak, I just verified myself. Your call to System.gc()
> does NOT guarantee that the GC will run. To check for leaks here is
> the procedure:
>
> - Run the app
> - Run adb shell dumpsys meminfo | grep -A 12 name.of.the.app.processs
> - Look at the count of Activities and ViewRoots
> - Run DDMS
> - Force a GC on the app's process
> - Force a GC on system_server
> - Force a GC on the app's process
> - Run adb shell dumpsys meminfo | grep -A 12 name.of.the.app.processs
> - Look at the count of Activities and ViewRoots
> (Repeat these steps)
>
> You will see that while the number of Activities/ViewRoot does
> increase temporarily, it always goes back down the normal numbers.
>
>
>
>
> --
> Romain Guy
> Android framework engineer


Romain,

thank you for your reply, now I see
the number of Activities/ViewRoot goes
back to the normal numbers but I still
believe that context is kept by someone.

yes, since Activities are finally freed its
not 'static' memory leak but can
lead to some rather serious problems
if for example someone changes
orientation quite frequently.

take NotifyWithText demo again

this is what I done to reproduce the problem:

I tried to add 'fake' field to my Activity:

int[] mNotUsedIntArray;

and in onCreate I allocate it:

mNotUsedIntArray = new int[500000];

here I allocate in my activity ~2M bytes
of memory

then I try to run that sequence 7/8 times:

run app, show toast, exit app

do it rather fast and finally you will see
OOM Error

I think if the references of my Activity were
not kept by someone the system would
gc() them during the allocation of field
mNotUsedIntArray (when there is no
available free memory), but it doesn't.

if you repeat that sequence quite slow -
one step per say two minutes you will not
see OOM Error
imho most likely the references are released
upon some timer action.

do you agree, or I'm missing something?

thanks
pskink

--~--~---------~--~----~------------~-------~--~----~
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