Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Are there any tools that allow offline analysis (including summary/sorting/sifting) of an .hprof file? Or can you run VisualVM, hat etc in batch mode?

I'm interested in something that can take an input .hprof file, crunch it and generate reports.

I assume you would need to pass in a bunch of options to configure the report, so if you know any helpful tips, please weigh in.

Preferably scriptable so I could run a bunch at once.

like image 754
user331465 Avatar asked Dec 03 '10 16:12

user331465


People also ask

How do you analyze a Java heap dump 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 a .hprof 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.


2 Answers

Eclipse Memory Analyzer does everything you need.

like image 157
user85155 Avatar answered Sep 22 '22 06:09

user85155


You can use jhat to parse/navigate the memory dump of an .hprof file.

$ jhat heapdump.hprof Reading from heapdump.hprof...  Started HTTP server on port 7000 Server is ready. 

The tool comes with the JDK.

like image 35
user2426263 Avatar answered Sep 22 '22 06:09

user2426263