I developed an application that uses lots of images on Android.
The app runs once, fills the information on the screen (Layouts
, Listviews
,
To avoid this problem you can use native method Bitmap.recycle()
before null
-ing Bitmap
object (or setting another value). Example:
public final void setMyBitmap(Bitmap bitmap) {
if (this.myBitmap != null) {
this.myBitmap.recycle();
}
this.myBitmap = bitmap;
}
And next you can change myBitmap
w/o calling System.gc()
like:
setMyBitmap(null);
setMyBitmap(anotherBitmap);