Thursday, June 11, 2009

android memory usage with hprof

Android provides some mechanisms to generate hprof data:
  1. 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.
  2. The android provides monkey tool (random testing tool), with --hprof option will generate hprof file within /data/misc folder.
  3. 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").
Some tips:
  1. The folder /data/misc shall have 777 permissions.
  2. The hprof file format is heap-dump-tm-pid.hprof-head and heap-dump-tm-pid.hprof if android 1.1 release is used.
  3. The hprof file format is heap-dump-tm-pid.hprof if android 1.5 release is used.
  4. 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.
  5. Convert the hprof to standard hprof format: hprofconv dump.hprof out_dump.hprof
  6. 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.
Some resources:
  1. Eclipse MAT: http://www.eclipse.org/mat/
  2. MAT standalone: MemoryAnalyzer-Incubation-0.7.0.20081210-win32.win32.x86.zip
  3. Hprofconv: http://bigflake.com/HprofConv.c.txt

20 comments:

Unknown said...

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 ?

zcocorporation said...
This comment has been removed by the author.
sasha said...

One of the biggest reasons for smartphones from Samsung, Sony Ericsson and Motorola to do roaring business is thanks to the presence of the android applications in them

best android apps

best iphone apps

Mark said...

A visit to any supermarket will show you shelves of varied products available for carpet cleaning.

home products
energy drinks
vitamin supplements
Cleaning products

Fara Fae said...

Thanks for making such a killer blog. I arrive on here all the time and am floored with the fresh information here!You are great!

3d ultrasounds

Anonymous said...

Very happy to see your article, I very much to like and agree with your point of view. Thank you for sharing. At the same time,i love best pram very much .Welcome to look at my website and blog articles.Hope we can become good friends, and exchange and to help each other! Thanks!!
wedding dresses

Anonymous said...

Not bad post. I just discovered your blog site and wished to state that I've got in fact really enjoyed browsing your blog post posts.
Compare Life Insurance Policies

Ducen said...

Let's go over what you can backup, what you don't need to backup, and ... We've already talked about contacts, but having a record of calls.

affordable auto sales

Ducen said...

wat a nyc article private by you i really like it dude saying it with core of my heart. It is completely a relevant and revealing article
Vitamin for Stress

Farrah Khan said...

Excellent article that will provide the incentive and basis for my works. I wonder if I can mention the article as a bibliographic reference in my work. Thanks!
~^- organic supplements -^~

Farrah Khan said...

Thanks for going to so much trouble to make everything so user friendly and easy to understand.

find doctors list | doctor ratings

Opensource Development said...

Valuable information about the google android. Joomla developers

Ducen said...

t is truly a nice and useful piece of information. I’m satisfied that you shared this useful info with us. Please keep us up to date like this. Thank you for sharing.
Hotels in Sri lanks Colombo | Sri lanka tourism | cars ,cars rentals Colombo sri lanka

Unknown said...

This is a fantastic post,very well authored and easy to understand.Thanks so much for this
Latestcinenews

The Real Estate Guy said...

Good information here!
Thanks!

The Real Estate Guy

Wine for Beginners said...

Great post, good to know!
I also share details on wines.

Wines for Beginners

The Silicone Tube Shop said...

Thanks for sharing!

The Silicone Tube Shop

Gary said...

Great, thanks for that... Was really wondering about it.

Cheers,
Gary

Gary said...

Great post, thanks for the info!
Helped a lot in my code.

OneGallery App

Unknown said...

You made some good points there. I searched this topic and found out that most people will agree with your blog. Big thanks for the useful info...Just continue on sharing your talent and creations. Hope you can do more, and I'll keep an eye on that.Thanks.hope you let us know more about this. I am really interested to know it. Looking forward for more. Thanks!
Become Ordained Online