我有一個名爲Test1的簡單活動。啓動其他活動時ImageView內存泄漏
這是佈局代碼。
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/test"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<ImageView
android:id="@+id/imageview1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:adjustViewBounds="true"
android:src="@drawable/load"
android:scaleType="fitXY" />
</RelativeLayout>
在我onDestory
的方法,我鬆開mImageView
資源和Android的分佈是,mImageView
記憶真的被回收。
@Override
protected void onDestroy() {
super.onDestroy();
releaseImageViewResource(mImageView);
layout.removeView(mImageView);
mImageView.setVisibility(View.GONE);
mImageView.setImageDrawable(null);
mImageView = null;
}
但是當我啓動其他簡單的活動中,mImageView
該內存不能被回收。爲什麼以及如何解決問題?
'但是當我開始其他簡單活動時?這是什麼意思?你的意思是,你是從ImageView開始的第一項活動,然後從該活動開始另一項活動?你能詳細說明一下嗎? – Henry
完成那個你寫的onDestroy或者其他onDestroy()不會被調用的活動, – notTdar