Friday, June 6, 2014

How to use jmap and jhat

1. Using jmap to take a memory dump of process 1234, save the dump file as "heapdump".

[root]# jmap -dump:format=b,file=heapdump -F 1234
Attaching to process ID 1234, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 20.45-b01
Dumping heap to heapdump ...
Finding object size using Printezis bits and skipping over...
Finding object size using Printezis bits and skipping over...
Finding object size using Printezis bits and skipping over...
Finding object size using Printezis bits and skipping over...
Finding object size using Printezis bits and skipping over...
Finding object size using Printezis bits and skipping over...
Heap dump file created

2.  Using jhat to analyze the file "heapdump" and start a http service.

jhat -J-Xmx256m heapdump

3. Open browser to http://<IP of the server>:7000/

"Show heap histogram"
"Show instance counts for all classes (excluding platform)"

Then we can identify the super class with most instances.

No comments:

Post a Comment

Popular Posts