轉自http://www.418log.org/post-32.html
1)進入shell
在桌面點開始--運作 輸入cmd 點确定 或打開 cmd.exe 進入sdk tools目錄如:
<code>1</code>
<code>C:\Users\Administrator>d:</code>
<code>2</code>
<code>C:\Users\Administrator>cd D:\Program Files\android-sdk\platform-tools></code>
檢視本機已經啟動的模拟器
<code>D:\Program Files\android-sdk\platform-tools>adb devices</code>
<code>List of devices attached</code>
<code>3</code>
<code>emulator-</code><code>5554</code> <code>device</code>
進入shell指令行
adb shell
後顯示為# 如果顯示為$ 輸入su
exit 退出
在 adb shell 指令前運作 adb remount
(2)進入shell後
ls
cd data
下面還有個data,進入後下面是程式的包
可以直接輸入monkey -p com.jd.customer -v 50,後會自動切換界面
也可以退出shell,在指令行輸入,
adb shell monkey -p com.jd.customer -v 50 --hprof 生成報告
.hprof 檔案會自動儲存在SD卡上,然後把.hprof 檔案拷貝到PC上的
\ android-sdk-windows\tools目錄下。
這個由DDMS生成的檔案不能直接在MAT打開,需要轉換。運作cmd打開指令行,
cd到\ android-sdk-windows\tools所在目錄,并輸入指令
hprof-conv xxxxx.hprof yyyyy.hprof,其中xxxxx.hprof為原始檔案,
yyyyy.hprof為轉換過後的檔案。
轉換過後的檔案自動放在android-sdk-windows\tools 目錄下。
OK,到此為止,.hprof檔案處理完畢,可以用來分析記憶體洩露情況了。