Not seeing calls to the finalizers is not an indication your ListViews
are not being GC'd. Just by having an overriden finalize() method, you
are keeping the objects longer in memory (because they are enqueued
for finalization.) Instead of relying on finalizers, use a heap dump
from DDMS and inspect it in MAT (Memory Analyzer Tool, an Eclipse
plugin.)

On Sat, Oct 23, 2010 at 1:09 PM, John Gaby <[email protected]> wrote:
> I have a very simple application which has a problem with getting
> ListViews to be freed by the GC.  I have a ViewGroup which has a
> ListView.  When the page with the ViewGroup no longer has any
> references to it, and I force a GC, the ListView is not freed.
>
> The project in question is quite small and can be found at
> http://gabysoft.com/download/MemoryLeak.zip.  If you run it, the first
> page has a button and a ListView (which has no items so you cannot see
> it).  When you press the button it switches to a second page which has
> just a button.  When you press the button on the second page, it
> creates a new ViewGroup and ListView and sets that as the current
> view.  Thus, every time you switch pages, a new ViewGroup/ListView is
> created, and all references to the old one go away.  Hence the old one
> should be GC'd.  However if you switch views 20 times and then force a
> GC you will see that the ListViews are never freed (i.e. their
> finalize method (which is logged) is not called).
>
> Now here is the really weird part.  This happens ONLY if I build my
> project using Eclipse.  If I use Ant to build and install the project,
> the ListViews are all freed when I do a GC as you would expect.  Why
> would the Eclipse version exhibit this behavior?
>
> --
> 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
>



-- 
Romain Guy
Android framework engineer
[email protected]

Note: please don't send private questions to me, as I don't have time
to provide private support.  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 [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