我认为这个问题经常被问到,但在我这样做之后
bitmap.release;
bitmap = null;
在 Fragment 的 onDestroy 中,使用的内存与以前一样多。
fragment :
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
initializeViews();
croppedBitmap = BitmapFactory.decodeFile("/.../0001.jpeg");
imageView.setImageBitmap(croppedBitmap);
fabCreate.setOnClickListener(...); //never called
}
@Override
public void onDestroy() {
clearMemory();
super.onDestroy();
}
void clearMemory(){
fabCreate.setOnClickListener(null);
imageView.setImageBitmap(null);
imageView = null;
croppedBitmap.recycle();
croppedBitmap = null;
java.lang.System.gc();
}
最佳答案
关于java - Android - 释放位图内存,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51826681/