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

7

26

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.

Ruff answered 3/12, 2010 at 16:18 Comment(1)
By "offline" do you mean "headless"? I think of "offline" as meaning "outside the context of the running JVM instance".Johnston
E
20

Eclipse Memory Analyzer does everything you need.

Eradicate answered 3/12, 2010 at 16:44 Comment(2)
can you add command line switches to say "crunch this .hprof offline"?Ruff
Look for ParseHeapDump.sh (.bat on Windows) in this FAQ: wiki.eclipse.org/MemoryAnalyzer/FAQHollywood
P
14

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.

Pendragon answered 16/9, 2013 at 14:13 Comment(0)
J
2

Can you use jmap -histo ? What sort of report are you looking to extract?

Joniejonina answered 3/12, 2010 at 16:23 Comment(2)
jmap -histo does not work against a .hprof file ; it expects a pidRuff
Basically anything that would help identify memory leaks. Offhand I'd say 'biggest objects' --both shallow and deep.Ruff
T
2

hard to beat yourkit java profiler. It costs money, but it is worth every penny.

Triacid answered 3/12, 2010 at 17:1 Comment(1)
but can you run heap dump analysis "in batch", i.e. via a script to generate the reports rather than waiting...waiting..waiting...while it loads and churns...?Ruff
M
1

Also, if you use IntelliJ IDEA, you can open *.hprof memory snapshots, too: Run | Open Profiler Snapshot | Open

Official documentation: https://www.jetbrains.com/help/idea/analyze-hprof-memory-snapshots.html

Mccain answered 1/12, 2020 at 20:30 Comment(0)
H
0

Es MAT (http://www.eclipse.org/mat/) is the way to go. Check http://kohlerm.blogspot.com/search/label/memory, especially http://kohlerm.blogspot.com/2009/07/eclipse-memory-analyzer-10-useful.html

Hardcastle answered 20/5, 2011 at 13:2 Comment(0)
P
0

JDK6 comes with jhat which parses and creates an html report.

http://docs.oracle.com/javase/6/docs/technotes/tools/share/jhat.html

Pretense answered 31/10, 2012 at 0:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.