标签:
抓取HPROF log
1. GUI
可以通过 adt-bundle-windows-x86_64-20140702\sdk\tools\monitor.bat来抓取。
打开软件,选中相应的包,比如“com.android.mms”,然后点击"Dump HPROF file" 按钮即可。
2.通过代码
在编写代码的时候,如果想保存HPROF文件,使用android.os.Debug.dumpHprofData()函数即可。
xxxButton.setOnClickListener(new View.OnClickListener() { public void onClick(View view) { android.os.Debug.dumpHprofData("/sdcard/com.android.mms.hprof"); } }
3.命令行
查找到的是JAVA的命令行工具。
http://docs.oracle.com/cd/E19798-01/821-1752/beafo/index.html
#java -Xrunhprof:help HPROF: Heap and CPU Profiling Agent (JVMTI Demonstration Code) hprof usage: java -agentlib:hprof=[help]|[<option>=<value>, ...] Option Name and Value Description Default --------------------- ----------- ------- heap=dump|sites|all heap profiling all cpu=samples|times|old CPU usage off monitor=y|n monitor contention n format=a|b text(txt) or binary output a file=<file> write data to file java.hprof[{.txt}] net=<host>:<port> send data over a socket off depth=<size> stack trace depth 4 interval=<ms> sample interval in ms 10 cutoff=<value> output cutoff point 0.0001 lineno=y|n line number in traces? y thread=y|n thread in traces? n doe=y|n dump on exit? y msa=y|n Solaris micro state accounting n force=y|n force output to <file> y verbose=y|n print messages about dumps y Obsolete Options ---------------- gc_okay=y|n Examples -------- - Get sample cpu information every 20 millisec, with a stack depth of 3: java -agentlib:hprof=cpu=samples,interval=20,depth=3 classname - Get heap usage information based on the allocation sites: java -agentlib:hprof=heap=sites classname
转化HPROF log
使用adt-bundle-windows-x86_64-20140702\sdk\platform-tools\hprof-conv.exe来转化。
hprof-conv a.hprof b.hprof
标签:
原文地址:http://www.cnblogs.com/miniren/p/4710302.html