I use Eclipse MAT to analyse hprof files. It is very good but if you have a 2Gb heap dump then you need to run MAT with a 2Gb+ heap size itself to be able to load the complete heap dump.
I was wondering if anyone knows of a tool that could analyse a 2Gb hprof file without using that much memory itself (e.g. it doesn't load the complete file but somehow walks through it)? This would be useful if a hprof file gets generated on a customer server as I could then run some analysis on the server instead of trying to copy a 2Gb file over a VPN.
Heap dumps are usually stored in binary format hprof files. We can open and analyze these files using tools like jhat or JVisualVM. Also, for Eclipse users, it's very common to use MAT.
We will first start the Memory Analyzer Tool and open the heap dump file. In Eclipse MAT, two types of object sizes are reported: Shallow heap size: The shallow heap of an object is its size in the memory. Retained heap size: Retained heap is the amount of memory that will be freed when an object is garbage collected.
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 jmap -dump option to obtain a heap dump at runtime; Use jconsole option to obtain a heap dump via HotSpotDiagnosticMXBean at runtime; Heap dump will be generated when OutOfMemoryError is thrown by specifying -XX:+HeapDumpOnOutOfMemoryError VM option; Use hprof.
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.
The latest versions of YourKit handle large heap dumps much better than before. I've had good success with it and highly recommend it. A long time ago there was a tool called Auptyma by Virag Saksena, but it appears that it may have been bought by Oracle.
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