Tool for Analyzing Large Java Heap Dumps

Tool for analyzing large Java heap dumps

Normally, what I use is ParseHeapDump.sh included within Eclipse Memory Analyzer and described here, and I do that onto one our more beefed up servers (download and copy over the linux .zip distro, unzip there). The shell script needs less resources than parsing the heap from the GUI, plus you can run it on your beefy server with more resources (you can allocate more resources by adding something like -vmargs -Xmx40g -XX:-UseGCOverheadLimit to the end of the last line of the script.
For instance, the last line of that file might look like this after modification

./MemoryAnalyzer -consolelog -application org.eclipse.mat.api.parse "$@" -vmargs -Xmx40g -XX:-UseGCOverheadLimit

Run it like ./path/to/ParseHeapDump.sh ../today_heap_dump/jvm.hprof

After that succeeds, it creates a number of "index" files next to the .hprof file.

After creating the indices, I try to generate reports from that and scp those reports to my local machines and try to see if I can find the culprit just by that (not just the reports, not the indices). Here's a tutorial on creating the reports.

Example report:

./ParseHeapDump.sh ../today_heap_dump/jvm.hprof org.eclipse.mat.api:suspects

Other report options:

org.eclipse.mat.api:overview and org.eclipse.mat.api:top_components

If those reports are not enough and if I need some more digging (i.e. let's say via oql), I scp the indices as well as hprof file to my local machine, and then open the heap dump (with the indices in the same directory as the heap dump) with my Eclipse MAT GUI. From there, it does not need too much memory to run.

EDIT:
I just liked to add two notes :

  • As far as I know, only the generation of the indices is the memory intensive part of Eclipse MAT. After you have the indices, most of your processing from Eclipse MAT would not need that much memory.
  • Doing this on a shell script means I can do it on a headless server (and I normally do it on a headless server as well, because they're normally the most powerful ones). And if you have a server that can generate a heap dump of that size, chances are, you have another server out there that can process that much of a heap dump as well.

Are there tools to analyse large Java heap dumps without loading the complete hprof file?

hprof files have a format that doesn't really work well without loading it fully and then applying some cross-referencing afterwards.

However, you may be able to skip the hprof dump to get just basic information from the running VM by using jmap, jstack, and visualvm included in the JDK package.
Typical memory leaks for example should be visible from the jmap heap histogram already, as you might be able to guess the places that produce or retain objects just by looking at the number of instances of a particular class.

Recommendations for a heap analysis tool for Java?

YourKit : http://www.yourkit.com/

Pros:

  • The interface is clean and it's fast
  • It opened a large 5-gig heap dump where jProfiler grined to a halt. And it only needed 1-2 gigs of JVM ram to do so.

Cons:
Of course... it's not free :(

Tool or tricks to analyze offline Java heap dumps (.hprof)

Eclipse Memory Analyzer does everything you need.



Related Topics



Leave a reply



Submit