简体   繁体   中英

ListView Memory leak?

Hey I seem to be having some kind of memory leak issue with my listview. The list view activity is in a tab and each row downloads an image and displays it in an ImageView (tiling it as a backgroiund). I am using a cache similar to droidfu http://github.com/kaeppler/droid-fu/blob/master/src/main/java/com/github/droidfu/imageloader/ImageCache.java

Everything seems to work fine as I'm completely clearing the memory cache when it gets past 20 items and also completely clearing the disk cache when it gets past 0.5mb just to be safe. The problem occurs when I have a large list of items in the list (say 100) and I keep scrolling back and forth this list as fast as I can. Eventually I get these messages in Logcat:

Heap Massage needed (59892-byte external allocation too big)

Full GC (don't collect SoftReferences)

Clamp target GC heap from 16.277MB to 16.000MB

Try and trim Heap Source

Full GC (collect SoftReferences)

And a whole bunch of those which lead to a force close. I'm not too sure what the problem is or how to go about fixing it :S

Thanks!

Here is the full log: http://pastebin.com/MghMdbxS

Turns out its the problem is with too many AsyncTask/Thread objects being created. I am using the code from http://code.google.com/p/android-imagedownloader/ and not sure how to get this fixed...

A good place to start is:

http://kohlerm.blogspot.com/2009/04/analyzing-memory-usage-off-your-android.html

It's a little complex to get a dump, but will give you a nice point-of-time static analysis. You will need the Eclipse memory analysis tool (MAT) also:

http://www.eclipse.org/mat/

Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM