android高手成长之路--Tools之MAT
1) 安装
Help->SoftWare Updates and Add-ons->Available software-> Add Site :
http://download.eclipse.org/mat/1.0/update-site/
2) 生成.hprof文件
adb shell
chmod 777 /data/misc (默认的HProf (Heap Profile) 放在/data/misc,需要改写权限为777)
exit
adb shell ps (查看你的进程号)
adb shell kill -10 pid (你准备分析的进程号)
这个时候你可能在logCat中看到一些如下信息:
adb shell logcat
I/dalvikvm( ): threadid=7: reacting to signal 10 I/dalvikvm( ): SIGUSR1 forcing GC and HPROF dump I/dalvikvm( ): hprof: dumping VM heap to "/data/misc/heap-dump-tm- pid.hprof-hptemp". I/dalvikvm( ): hprof: dumping heap strings to "/data/misc/heap-dump-tm124026 3144-pid.hprof". I/dalvikvm( ): hprof: heap dump completed, temp file removed D/dalvikvm( ): GC freed 1292 objects / 92440 bytes in 11 sec D/dalvikvm( ): GC freed 215 objects / 9400 bytes in 963m
现在你可以将heap dump 信息拷贝到某个地方,以便我们一会用eclispse的 MAT来分析:
adb pull /data/misc/heap-dump-tm-pid.hprof ××××目录
Help->SoftWare Updates and Add-ons->Available software-> Add Site :
http://download.eclipse.org/mat/1.0/update-site/
2) 生成.hprof文件
adb shell
chmod 777 /data/misc (默认的HProf (Heap Profile) 放在/data/misc,需要改写权限为777)
exit
adb shell ps (查看你的进程号)
adb shell kill -10 pid (你准备分析的进程号)
这个时候你可能在logCat中看到一些如下信息:
adb shell logcat
I/dalvikvm( ): threadid=7: reacting to signal 10 I/dalvikvm( ): SIGUSR1 forcing GC and HPROF dump I/dalvikvm( ): hprof: dumping VM heap to "/data/misc/heap-dump-tm- pid.hprof-hptemp". I/dalvikvm( ): hprof: dumping heap strings to "/data/misc/heap-dump-tm124026 3144-pid.hprof". I/dalvikvm( ): hprof: heap dump completed, temp file removed D/dalvikvm( ): GC freed 1292 objects / 92440 bytes in 11 sec D/dalvikvm( ): GC freed 215 objects / 9400 bytes in 963m
现在你可以将heap dump 信息拷贝到某个地方,以便我们一会用eclispse的 MAT来分析:
adb pull /data/misc/heap-dump-tm-pid.hprof ××××目录
3) 使用
使用sdk安装目录下面的hprof-conv工具将heap-dump-tm-pid.hprof转换一下,eclipse->windows->open perspective->other->memory 易做图yzer 导入你刚刚生成的.hprof文件
4) 分析
详解: http://www.eclipse.org/mat/about/screenshots.php
摘自:androidzhaoxiaogang的专栏
补充:移动开发 , Android ,