5
我有A和B的活动。当我从活动A开始活动B时,我在活动B上设置了静态位图变量。我在屏幕上显示该位图并旋转它。内存使用率不降低甚至我回收位图
当活动B完成,我回收上的onDestroy()方法,但内存使用量没有减少所有位图。
@Override
protected void onDestroy() {
super.onDestroy();
if (bitmap90 != null) {
bitmap90.recycle();
bitmap90 = null;
}
if (bitmap180 != null) {
bitmap180.recycle();
bitmap180 = null;
}
if (bitmap270 != null) {
bitmap270.recycle();
bitmap270 = null;
}
if (mBitmap != null) {
mBitmap.recycle();
mBitmap = null;
}
if (((BitmapDrawable) ivOriginal.getDrawable()).getBitmap() != null) {
((BitmapDrawable) ivOriginal.getDrawable()).getBitmap().recycle();
ivOriginal.setImageDrawable(null);
}
if (((BitmapDrawable) ivOriginal90.getDrawable()).getBitmap() != null) {
((BitmapDrawable) ivOriginal90.getDrawable()).getBitmap().recycle();
ivOriginal90.setImageDrawable(null);
}
System.gc();
}
也许你在其他地方持有对你的位图的引用。通常不鼓励使用静态属性。你为什么不把你的位图保存在一个文件中,然后在你的B活动中读取它? –