即使我回收位图,内存使用量也不会减少 [英] Memory usage does not decrease even I recycle bitmaps
本文介绍了即使我回收位图,内存使用量也不会减少的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有A和B活动.从活动A开始活动B时,我在活动B上设置了静态位图变量.我在屏幕上显示该位图并旋转它.
I have A and B activities. When I start activity B from activity A, I set static bitmap variable on activity B. I show that bitmap on the screen and rotate it.
活动B完成后,我在onDestroy()方法上回收了所有位图,但内存使用并未减少.
When activity B is finished, I recycle all bitmaps on onDestroy() method but memory usage is not decreasing.
@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();
}
推荐答案
查看全文