導航:首頁 > 操作系統 > androidmat地址

androidmat地址

發布時間:2023-08-11 17:52:42

android用MAT檢測內存泄漏問題。。

Eclipse 有個插件工具MAT(Memory Analyzer Tool)可以幫助定位內存泄漏的對象。
安裝MAT Update site: http://archive.eclipse.org/mat/1.1/update-site/
用DDMS工具Dump出問題App的.hprof文件 比如com.world.test2.hprof Dump之前最好先運行一下GC "Cause GC" , 確保mp出來的是還不能回收的對象等。
用SDK tools下工具hprof-conv.exe 做轉換 hprof-conv com.world.test2.hprof appleak.hprof
用Eclipse 「Open Head Dump」打開新轉換的.hprof 文件--appleak.hprof 查看圖形化界面,一個一個檢查懷疑的點。
總結: MAT tool不會直接告訴你哪裡內存泄漏,但是會列出懷疑的對象,需要你仔細檢查這些對象為什麼沒有被釋放掉。
下面是測試code, 在Android 4.2.2上測試過。 1. 此種情況可以引起Activity無法回收的情況,因為直接用類似private static Activity a0引用創建的Activity,導致Activity無法回收。 2. 此種情況沒有引起Activity 無法回收的情況。 按理說這種情況應該也會導致靜態Drawable 鎖定Activity, 引用關系mBackground1-->Button-->Activity. 待分析
public class MainActivity extends Activity implements Button.OnClickListener{

final private static String TAG = "MainActivity";

private static Drawable mBackground1;

private static Drawable mBackground2;

private static Drawable mBackground3;

private static Drawable mBackground4;

private static Activity a0 ;

private static Activity a1 ;

private static Activity a2 ;

private static Activity a3 ;

private static Activity a4 ;

/*

* Shutdown intent

*/

private final String INTENT_ACTION_REQUEST_SHUTDOWN =

"android.intent.action.ACTION_REQUEST_SHUTDOWN";

@Override

public void onCreate(Bundle savedInstanceState) {

Log.v(TAG, "onCreate Activity="+this);

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

//1

if(false){

if(a0 == null){

a0 = this;

Log.v(TAG, "onCreate Activity a0="+a0);

}

else if(a1 == null){

a1 = this;

Log.v(TAG, "onCreate Activity a1="+a1);

}

else if(a2 == null){

a2 = this;

Log.v(TAG, "onCreate Activity a2="+a2);

}

else if(a3 == null){

a3 = this;

Log.v(TAG, "onCreate Activity a3="+a3);

}

else if(a4 == null){

a4 = this;

Log.v(TAG, "onCreate Activity a4="+a4);

}

}

//set up button listener

Button myButton = (Button)findViewById(R.id.button_poweroff);

myButton.setOnClickListener(this);

myButton = (Button)findViewById(R.id.button_reboot);

myButton.setOnClickListener(this);

//2

if (mBackground1 == null) {

Log.v(TAG, "onCreate mBackground1");

mBackground1 = getResources().getDrawable(R.drawable.adbroot_004);

myButton.setBackgroundDrawable(mBackground1);
}

else if(mBackground2 == null){

Log.v(TAG, "onCreate mBackground2");

mBackground2 = getResources().getDrawable(R.drawable.test002);

myButton.setBackgroundDrawable(mBackground2);

}

else if(mBackground3 == null){

Log.v(TAG, "onCreate mBackground3");

mBackground3 = getResources().getDrawable(R.drawable.test003);

myButton.setBackgroundDrawable(mBackground3);

}

else if(mBackground4 == null){

Log.v(TAG, "onCreate mBackground4");

mBackground4 = getResources().getDrawable(R.drawable.adbroot_003);

myButton.setBackgroundDrawable(mBackground4);

}

}

❷ android mat 什麼意思

簡單的說就是android的一個內存分析工具。幫助優化你的app。

MAT(Memory Analyzer Tool),一個內存分析工具,是一個快速、功能豐富的JAVA heap分析工具,它可以幫助我們查找內存泄漏和減少內存消耗。使用內存分析工具從眾多的對象中進行分析,快速的計算出在內存中對象的佔用大小,看看是誰阻止了垃圾收集器的回收工作,並可以通過報表直觀的查看到可能造成這種結果的對象。

你可以把它集成到android studio或者Eclipse裡面。然後使用它分析你的app。具體的使用方法你可以網上搜索。

閱讀全文

與androidmat地址相關的資料

熱點內容
傳統8051單片機介紹 瀏覽:627
app拉新公司如何運營 瀏覽:617
槍法pdf 瀏覽:61
ios如何設置安卓虛擬返回鍵 瀏覽:696
mysql命令執行sql 瀏覽:93
惠普內嵌伺服器怎麼打開 瀏覽:410
cmd命令查看網路 瀏覽:817
程序員秘密 瀏覽:928
如何宣傳app引流 瀏覽:68
圖說紅樓夢中央編譯 瀏覽:170
php查詢賦值 瀏覽:268
java程序員面試寶典第四版pdf 瀏覽:929
2021流行加密加長睫毛膏 瀏覽:641
怎麼用windows自帶編譯器 瀏覽:394
phpmanager64下載 瀏覽:139
有車以後app的活動在哪裡 瀏覽:147
乘積的n階如何編譯 瀏覽:108
手機音頻轉換app哪個好用 瀏覽:567
怎麼快速展開全部切割清單中文件夾 瀏覽:677
內網如何打開伺服器遠程桌面連接 瀏覽:983