I've got an app which fetches bitmaps in threads, then puts the bitmaps into a global mem cache. On a 2.2 emulator, I get a reproducable out-of-memory error after loading enough bitmaps (they're in a listview):
FATAL EXCEPTION: pool-1-thread-1
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
...
The heap looks stable (3.3mb), and I wonder if I can't see the amount of memory growing because I think in the 2.2 os, bitmap memory is stored separately? I keep doing hprof dumps and viewing them in MAT, and my object counts look as expected.
Running the app on an ICS phone doesn't exhibit the same problem (yet, maybe just has more memory etc). I think in the later OSs they keep bitmap memory as part of the heap?
In either case, is there a way to see which Bitmap instances have been allocated by my app? The hprof dumps just show a total count system-wide I think. But I can't see where they were allocated from.
I'm using:
android.support.v4.util.LruCache<String, Bitmap>
as a memcache - it almost seems like the bitmap data isn't being cleaned up after entries get evicted (I set the cache to have a 5mb cap). I remember there being methods on Bitmap like recycle(), maybe they're not getting cleaned up properly?
Thanks