Skip to content

Instantly share code, notes, and snippets.

@bepcyc
Created January 30, 2012 12:28
Show Gist options
  • Save bepcyc/1704155 to your computer and use it in GitHub Desktop.
Save bepcyc/1704155 to your computer and use it in GitHub Desktop.
The way to free Bitmap memory
/**
* The way to free memory arranged for Bitmaps in native memory or just not GC'ed
* @source <a href="http://stackoverflow.com/a/7783511/918211">StackOverflow Thread</a>
*/
public static void stripImageView(ImageView view) {
if (view.getDrawable() instanceof BitmapDrawable) {
((BitmapDrawable) view.getDrawable()).getBitmap().recycle();
}
view.getDrawable().setCallback(null);
view.setImageDrawable(null);
view.getResources().flushLayoutCache();
view.destroyDrawingCache();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment