As has been detailed by many helpful sites, one way to analyze memory usage of Android apps is to execute a "kill -10 [PID]" to trigger an HPROF dump. This seems to work on some devices, and the logcat normally contains something like this:
I/dalvikvm(32170): threadid=3: reacting to signal 10
I/dalvikvm(32170): SIGUSR1 forcing GC and HPROF dump
I/dalvikvm(32170): hprof: dumping VM heap to "/data/misc/heap-dump-tm1302633572-pid32170.hprof-hptemp".
I/dalvikvm(32170): hprof: dumping heap strings to "/data/misc/heap-dump-tm1302633572- pid32170.hprof".
I/dalvikvm(32170): hprof: heap dump completed, temp file removed
However, on other devices, executing the "kill -10" results in this:
I/dalvikvm( 5687): threadid=4: reacting to signal 10
I/dalvikvm( 5687): SIGUSR1 forcing GC (no HPROF)
All the devices I'm trying this on are rooted and I've made sure to chmod /data/misc to 777. I don't get any error messages after executing "kill -10".
In case it's helpful, here are the devices where I do get an HPROF dump: HTC ACE (Desire HD), HTC G1, HTC Nexus One (T-Mobile)
And here are the devices where I do NOT get an HPROF dump: Nexus S, Droid, Droid X, Nexus One (AT&T)
Why can't I get an HPROF dump from certain devices and is there anything I can do to allow me to get the dumps?
hprof files generated in log folder in BI servers. hprof files are heap dump of the memory of java-based processes. Huge hprof files most commonly indicate out of memory issues about the related processes. These hprof files can be configured at startup to track and monitor memory performance issues.
A heap dump is a snapshot of all the objects that are in memory in the JVM at a certain moment. They are very useful to troubleshoot memory-leak problems and optimize memory usage in Java applications. Heap dumps are usually stored in binary format hprof files.
If you have a heap dump file saved on your local system, you can open the file in Java VisualVM by choosing File > Load from the main menu. Java VisualVM can open heap dumps saved in the . hprof file format. When you open a saved heap dump, the heap dump opens as a tab in the main window.
Use DDMS. Click on the "Dump HPROF File" toolbar icon -- it looks like a half-full can with a downward-pointing arrow. Worked like a charm when I tried it just now on a Nexus S.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With