Hey all-

I'm fairly new to Android development and Java development and I've
discovered that an app I created recently has a serious memory leak
issues.

Due to the nature of this app, potentially Activities could be added
to the stack ad infinitum.  To make matters worse, every activity
downloads a lot of images from web feeds.

I have read a lot about bitmaps leaking in android and have
implemented many suggestions from the web about how to release these
explicitly.   I'm mainly doing this in the onStop override for each
Activity.  It seems that I still have a lot of leaking going on, I
have some lines of code tracking the memory build up as I go.

I have a few pointed questions about what I'm doing that I'm hoping
getting answers to will correct my understanding and my code:

1.) My understanding is that if an object (an Activity in this case)
is holding objects, upon being destroyed the memory for those objects
should also marked for GC as long as nothing else is holding a
reference to it.   Is that correct?  Because of that, I have been
using the current Activity as the context for any Adapters I
instantiate as well, assuming that would pair the Adapters and any
views they are holding with the Activities lifecycle.
Is that more or less correct?

2.) If I start another activity from the current activity, what
context should I pass to the constructor of Intent?  Currently I've
been either using the current activity instance, or the view who's
onclicklistener has been triggered.

3.)  If I set a reference to a new object, the previous object it held
should be ready for GC, assuming nothing else is holding it, correct?

Any other thoughts or ideas around my problems would be appreciated as
well.   I have been finding the DDMS tool to be difficult to use to
trace back leaks to their origins.

Thanks!

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

Reply via email to