0

I am having an issue with bitmap recycle. I am displaying the bitmaps in a grid view . I have about 40-50 thumbnails. when I down load the thumb image from the url I cached it to disk. Set the bitmap on ImageView and call bitmap.recycle(). BUt I keep getting recycled bitmap cannot be used.

Any ideas on what might be happening. Thanks for your help. I am re-using the 'convert-view' in the getView() of the ImageAdapter

Regards -Chandu

Chandu
  • 1,049
  • 3
  • 11
  • 18

2 Answers2

2

My understanding of this is, you can't recycle a bitmap that is still being used. Furtheremore, as you are using an adpatable view you don't even know when an image will no longer be used.

The solution is to use weak references with the bitmaps to allow the carbage collector to take care of freeing up that memory when it is no longer needed.

Here is a guide: http://developer.android.com/training/displaying-bitmaps/process-bitmap.html

meeeee
  • 2,929
  • 3
  • 22
  • 25
0

The bitmap is still being used by the ImageView.

Juxtaposition
  • 646
  • 5
  • 10
  • I did not quite understand what you meant. On my screen the grid view is showing 6 imageviews with thumbnails. Once I set the bitmap for each thumbnail I want to recyle() to free up memory , because on scrolling the new thumbnails come into view and the imageView will be used again. Is this understanding correct. – Chandu Nov 06 '11 at 03:18
  • Are you trying to recycle Bitmaps that are currently being displayed? – Juxtaposition Nov 06 '11 at 03:45
  • Yes once I set the bitmap to imageview I am trying to call recycle and running into the issue. But I have seen examples here and on web where I saw recycle was being called right after setting the bitMap to the imageView – Chandu Nov 06 '11 at 06:23