Heap Dump

To get a heap dump of an existing application you need to know the PID of your java process.

To do this, you can use the jps command

jps -l

So for above, I can see the PID for the process is 5776

Once you know your PID you can use the jcmd to generate the heap dump

jcmd <pid> GC.heap_dump <file-path>

For above PID I can do


jcmd 5776 GC.heap_dump c:/temp/dump.hprof

To open the the heap dump, you can use YourKit or Open source tools such as Eclipse MAT tool

Using Eclipse MAT Tool we can open the Heap dump

Using the Eclipse MAT tool you can see the drill in the pie chat to list Objects and to see the incoming references, see the retain size of objects, see the paths to GC Root. MAT tool also has leak hunter tool to try to find problem areas.

Leave a Reply

Your email address will not be published. Required fields are marked *