Sunday, 15 September 2013

Android ListView showing images results in out of memory

Android ListView showing images results in out of memory

Okay,
I have what I think is an odd problem.
I load photos into a list view as the user scroll (meaning if picked up
from disk or online, it takes a little time and they "pop in")
1)
I ensure that I only fetch one image online + resize to 1/3 width at a
time (a lock) -- this is to ensure not e.g. 5 threads each are converting
a .jpg to bitmap at the same time. (Imagine a user scrolling very fast, it
would then be conceivable this could happen.)
2)
All images on disk are only 1/3 width
3)
While the bitmaps are scaled up to fit device width, I call recycle and
set bitmaps to null when used in the getView. (I am converting bitmaps to
a BitmapDrawable object which the listitem imageview uses in a
setImageDrawable call)
I am testing on a Samsung Galaxy II. Do you guys have any ideas on what
more I could try? Since I only max need to show 10 items, I would think it
should be possible...

No comments:

Post a Comment