Recycling ImageView Bitmaps

I encountered memory issues when displaying large jpegs (in series) in a slideshow-like activity. I learned that you need to recycle the bitmaps with a call to recycle():

ImageView img;
Bitmap bitmap = ((BitmapDrawable) img.getDrawable()).getBitmap();
bitmap.recycle();
img.setImageResource(imgID[currentImg]);

Note that ‘imgID’ is an array of resource IDs.

Advertisements
Published in: on January 18, 2012 at 6:26 pm  Leave a Comment  

The URI to TrackBack this entry is: https://sestoelemento.wordpress.com/2012/01/18/recycling-imageview-bitmaps/trackback/

RSS feed for comments on this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: