27

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.

Gray
  • 115,027
  • 24
  • 293
  • 354
user331465
  • 2,984
  • 13
  • 47
  • 77
  • By "offline" do you mean "headless"? I think of "offline" as meaning "outside the context of the running JVM instance". – Mark Peters Dec 03 '10 at 18:34

7 Answers7

20

Eclipse Memory Analyzer does everything you need.

durron597
  • 31,968
  • 17
  • 99
  • 158
user85155
  • 1,370
  • 16
  • 24
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.

malana
  • 5,045
  • 3
  • 28
  • 41
user2426263
  • 141
  • 1
  • 3
2

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

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
2

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

james
  • 1,230
  • 9
  • 4
  • 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...? – user331465 Dec 03 '10 at 17:19
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

Attila Csipak
  • 927
  • 2
  • 14
  • 34
0

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

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

robbin
  • 1,924
  • 4
  • 20
  • 26
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

kohlerm
  • 2,596
  • 1
  • 17
  • 22