jmap (rip jhat)



While developing Java applications is possible to see how the system behave by inspecting the ThreadDump, the HeapDump of the system or even the PermGen in JVisualVM – quite nice tool, all live actually.  The thing is to capture only what we need, so to capture the Heap Dump there are many ways and one of them is to use the jmap tool – which actually comes together with Jstack


Is a picture of the Java memory, a snapshot of it [1], it basically will contain the follow information [3]:

i. All Objects

ii. All Classes

ii. Threads info

ii. GC Root


This tool can help solve this issue by helping to capture the data and it’s actually shipped with JDK tool:

              jmap [options] pid

Using the option Jmap -heap we can print the heap info summary of GC:

jmap -heap   [pid]


jmap -clstats <pid>
to connect to running process and print class loader statistics
jmap -finalizerinfo <pid>
to connect to running process and print information on objects awaiting finalization
jmap -histo[:live] <pid>
to connect to running process and print histogram of java object heap
if the “live” suboption is specified, only count live objects
jmap -dump:<dump-options> <pid>
to connect to running process and dump java heap
jmap -? -h –help
to print this help message

live dump only live objects; if not specified,
all objects in the heap are dumped.
format=b binary format
file=<file> dump heap to <file>

Example: jmap -dump:live,format=b,file=heap.bin <pid>


To analyze the HeapDump we can use the Jhat tool, Java Heap Analysis Tool provided by default with the JDK, cause if you open the heap dump straight away, it will be shenanigans – since it is a binary file -actually an HPROF binary file.

2e32 0000 0000 0800 0001 682e 7487 5701
0000 0000 0000 0015 0000 7f0c a007 4be8
4d41 585f 534d 414c 4c5f 5445 4e01 0000
0000 0000 0019 0000 7f0c a416 7250 636f
6d70 7574 654d 6574 686f 6448 6173 6801
0000 0000 0000 0018 0000 7f0c a411 3940
636c 6173 7343 6173 7448 616e 646c 6572
0100 0000 0000 0000 0900 007f 0c48 1420
7801 0100 0000 0000 0000 0d00 007f 0ca4



Well, if you’re using JDK 8 or below, you can use this tool, otherwise,you must use JVisualVM, like is shown below:


JVisualVM – Heap Dump



[0] jmap

[1] This article, by the GCeasy Team, is quite neat and I almost stole the idea of fish something to put as a background image – like the whale. Their course description is really good here.

[2] Jstack video from Informatica Support youtube

[3] IBM Heap Dump


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s