如何将DDMS快照机制自动化? [英] How to automate the DDMS snapshot mechanism?
问题描述
的Android DDMS 提供的API?我需要自动执行本机堆的快照机制。或者是有分析DDMS机堆快照任何后期处理工具。
Does Android DDMS provide APIs ? I need to automate the snapshot mechanism for the native heap. Or is there any post processing tool for analysis DDMS native heap snapshots.
推荐答案
我通过快照假设你的意思堆转储。
I assume by snapshot you mean a heap dump.
从你的应用程序code你可以调用<一个href=\"http://developer.android.com/reference/android/os/Debug.html#dumpHprofData%28java.lang.String%29\"相对=nofollow> Debug.dumpHprofData()
转储数据。
From your app code you can call Debug.dumpHprofData()
to dump the data.
这是一个脚本可以调用
adb am dumpheap <process> <file>
其中,&LT;处理&gt;
是如您的进程ID或名称,&LT;文件&gt;
是转储文件名。之后,你可以 ADB拉
转储到您的计算机。
where <process>
is e.g. your process id or name, and <file>
is the dump file name. After that you can adb pull
the dump to your computer.
要分析堆转储,您可以使用例如或与jHat MAT。在这之前,你需要在运行转储 HPROF-CONV
(包含在Android SDK中),将其从Dalvik的格式标准的Java格式转换。
To analyze the heap dumps you can use e.g. jhat or MAT. Before that you need to run hprof-conv
(included in Android SDK) on the dump to convert it from Dalvik format to standard Java format.
延伸阅读:内存分析的Android应用程序一>
这篇关于如何将DDMS快照机制自动化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!