Um... a toast by definition sticks around for a while. If you are enqueing a bunch of toasts, they are all sticking around waiting to be displayed. They hold a reference on your context to load resources and such, so your context won't be released until all of the toasts are shown and dismissed.
On Tue, Jul 7, 2009 at 8:49 AM, skink <psk...@gmail.com> wrote: > > > > On Jul 7, 12:27 am, Romain Guy <romain...@google.com> 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 > > > > -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---