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

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

问题描述

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.

从您的应用代码中,您可以调用 Debug.dumpHprofData() 转储数据.

From your app code you can call Debug.dumpHprofData() to dump the data.

您可以从脚本调用

adb shell am dumpheap <process> <file>

其中 是例如您的进程 ID 或名称, 是转储文件名.之后,您可以adb pull转储到您的计算机.

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屋!

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