Android provides some mechanisms to generate hprof data:
- Dalvik VM will dump hprof file within /data/misc folder if SIGUSR1 and/or SIGQUIT signal is received. Manually send SIGUSR1 to process: kill -10 pid.
- The android provides monkey tool (random testing tool), with --hprof option will generate hprof file within /data/misc folder.
- In cupcake release, a new API has been introduced to generate a dump programmatically, the static method dumpHprofData(String fileName) of the Debug class. Example: Debug.dumpHprofData("xxx.hprof").
- The folder /data/misc shall have 777 permissions.
- The hprof file format is heap-dump-tm
-pid .hprof-head and heap-dump-tm -pid .hprof if android 1.1 release is used. - The hprof file format is heap-dump-tm
-pid .hprof if android 1.5 release is used. - If two files are generated, you need to join the two files into one: type heap-dump-tm
-pid .hprof-head > dump.hprof; type heap-dump-tm -pid .hprof >> dump.hprof. - Convert the hprof to standard hprof format: hprofconv dump.hprof out_dump.hprof
- Use JProfiler, Eclipse MAT, or other tools to open out_dump.hprof. I tried JProfiler and got the same problems as indicated in http://osdir.com/ml/android-porting/2009-04/msg00597.html.
- Eclipse MAT: http://www.eclipse.org/mat/
- MAT standalone: MemoryAnalyzer-Incubation-0.7.0.20081210-win32.win32.x86.zip
- Hprofconv: http://bigflake.com/HprofConv.c.txt
1 comments:
Wow, It's Very good Post
I was googling from 2-3 days, this is very first post I found telling various ways u can generate Hprof data.
I have Started with 3rd Option first ie: Debug.dumpHprofData("xxx.hprof")
I had also set permissions 777 to /data/misc , but still it says "can't Open xxx.hprof-hptemp : Read-Only file system"
So then I choose 1st Option ie: "kill -10 pid" & It Worked :)
Before all this I was using "Debug.startMethodTracing("scores")
& Debug.stopMethodTracing()" it created trace file in "/sdcard/scores.trace" I tried converting this using "hprof-conv" tool ,it given me error "Error : expecting 1.0.3", Can't I use trace file with hrof-conv tool ?
Post a Comment