views:

72

answers:

1

Hi,

I'm using ListView to display images which I provide through an ImageAdapter class. it works great on my device (and on many other devices which I tested it on), but somehow when I'm using the emulator and I'm long-pressing the up/down button - I'm getting an outOfMemory error after 10-15 seconds.

I tried clearing cache, canceling cache, etc. - nothing helped.

I know this crash is pretty rare (i couldn't reproduced it on any "real" device), but I can see on DDMS that "GC freed" are getting bigger during that long press and I can't find a way to clear them.

Any help will be appreciated, Tnx.

+1  A: 

You should decode with inSampleSize option to reduce memory consumption. http://stackoverflow.com/questions/477572/android-strange-out-of-memory-issue/823966#823966

Another option inJustDecodeBounds can help you to find correct inSampleSize value http://groups.google.com/group/android-developers/browse_thread/thread/bd858a63563a6d4a

You should also consider using inPurgeable option http://developer.android.com/reference/android/graphics/BitmapFactory.Options.html#inPurgeable. It allows system to free your memory to avoid OutOfMemory.

Fedor