Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 462
Mark Avatar asked Nov 25 '09 09:11

Mark


People also ask

How do I read large heap dump files?

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.

How do I analyze a heap dump bin file?

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.

How do I read Java heap dump file?

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.

Which tool helps in generating heap dumps?

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.


2 Answers

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.

like image 56
ankon Avatar answered Oct 09 '22 16:10

ankon


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.

like image 28
emmby Avatar answered Oct 09 '22 17:10

emmby