如何将DDMS快照机制自动化? [英] How to automate the DDMS snapshot mechanism?

查看:201
本文介绍了如何将DDMS快照机制自动化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

的Andr​​oid 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.

延伸阅读:内存分析的Andr​​oid应用程序

这篇关于如何将DDMS快照机制自动化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆