Friday, June 27, 2014

Get java process heap dump and analyse it by jhat


1. Get all java processes ids
17:17 ~/java $ jps -vm
14970 Jps -vm -Dapplication.home=/usr/lib/jvm/java-7-oracle -Xms8m
8850 org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar -data /home/rivanov/workspace -os linux -ws gtk -arch x86_64 -showsplash /home/rivanov/ ..................... -Dosgi.requiredJavaVersion=1.6 -XX:MaxPermSize=256m -Xms40m -Xmx512m

2. generate heap dump for application, in my case it is Eclipse.
17:19 ~/java $ jmap -dump:format=b,file=eclipse_heap.bin 8850
Dumping heap to /home/rivanov/java/git/dmt/eclipse_heap.bin ...
Heap dump file created

3. run jhat tool from JDK to analyse heap dump.
17:19 ~/java $ jhat eclipse_heap.bin 
Reading from eclipse_heap.bin...
Dump file created Fri Jun 27 17:19:37 PDT 2014
Snapshot read, resolving...
Resolving 1548547 objects...
Chasing references, expect 309 dots.....................................................................................................................................................................................................................................................................................................................
Eliminating duplicate references.....................................................................................................................................................................................................................................................................................................................
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.


4. Open in browser "http://localhost:7000/".
jhat is far from fancy heap dump analyser in comparison to Eclipse's MAT, jvisualvm, ...... but it is provided together with JDK and nothing should be installed .


No comments:

Post a Comment