Created
January 30, 2012 12:28
-
-
Save bepcyc/1704155 to your computer and use it in GitHub Desktop.
The way to free Bitmap memory
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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