-1

Facing out of memory issue when shows large thumbnails in each row of listview.

d.k.
  • 415
  • 4
  • 16
  • 1
    possible duplicate of [How do I do a lazy load of images in ListView](http://stackoverflow.com/questions/541966/how-do-i-do-a-lazy-load-of-images-in-listview) – GrIsHu Oct 16 '13 at 11:26
  • Sorry for write bad english. i will try to write well. – d.k. Oct 20 '13 at 12:44

1 Answers1

1

Clearly you're doing this wrong. Android gives you an extremely limited memory space. You should show thumbnails in your listview and only load the full images into memory (from the sdcard) when they've been selected. Also remember to recycle() your Bitmaps if you're loading them manually.

Yevgeny Simkin
  • 27,946
  • 39
  • 137
  • 236
  • 1
    All images are downloaded and that time i use option to image's bitmap. All images are in big size so i use option to reduce size but images become pixelated.(Basically this functionality is done by lazy load of images class.) – d.k. Oct 16 '13 at 11:34
  • What I'm saying is that you should keep your Images on the sdcard... NOT in memory. Lazy or not lazy... that's not the point. Download your images to disk, then load small thumbnails for your list views. When someone clicks on a thumb... THEN you show the larger image. Or if your list has images that are 1/2 the screen (or larger) then just load 2 or 3 images at a time and `recycle()` the ones that move out of the field of view. – Yevgeny Simkin Oct 16 '13 at 11:37
  • 1
    Yes, I have tried to save bitmap in sdcard but it takes much time to save large images. If you want to say that i should get thumbnail from saved file for each row of list view this case stuck the listview. Because in getview, i get thumbnail using BitmapFactory that takes time. – d.k. Oct 16 '13 at 11:41
  • Well... if your concern is performance then you'll have to pre-load these images to the SDCard in advance. There's no getting around the fact that you have a very limited memory space to work with. Make sure to request the larger heap space in your Manifest as well. – Yevgeny Simkin Oct 16 '13 at 19:44
  • 1
    Larger heap space request in manifest is supported from api level 12. But this feature also slow the app performance because gc becomes very slow in this case. – d.k. Oct 16 '13 at 20:07