2 Minutes To Code (β Version)

Eclipse Memory Analyzer - 2 minute tutorial

Get heap dump : How to get heap dump of a running jvm

Let's see how to get the jvm heap dump of our running java app.

First of all, get the process id of the running jvm. This can be done by using the unix comamnd ps or the unix command top. In the example below, we have got the process id using a platform-independent utility called jps that comes bundled with jdk downloads.

So, just run the command jps. It lists our program SpringStore with its process-id 3040. We will use this process-id with jmap comamnd below.

Now, jdk release bundle contains another utility called jmap. Run it using the command jmap -dump:format=b,file=myHeap.bin 3040. In this comamnd, we are asking jmap to genearte a heap dump of process id 3040 in b(binary) format and store it in the file myHeap.bin in present working directory.

Just grab the dump file myHeap.bin now and load it in Eclipse with MAT plugin installed (or standalone MAT) as shown in the next page.