FreeKB - Tomcat Create a heap dump (jmap,
Tomcat - Create a heap dump (jmap,

Let's say you want to create a heap dump of a running Tomcat JVM. First, you will need to get the PID of the Tomcat application server. On Linux, this can be done using the ps command. In this example, the PID of the JVM is 12345.

~]# ps -ef | grep jvm_name
root  12345  . . . 


The jmap command, which is included with some, but not all versions of Java, can be used. The which command can be used to determine if the jmap command is in your $PATH.

which jmap


If jmap is in your $PATH, something like this should be returned.



The jmap command can be used to create a heap dump. jmap is a command line tool included with Java. Following is the basic syntax of the jmap command. The PID of the JVM (12345 in this example) is used to create a heap dump of the running Tomcat JVM. This will create a file named heapdump.hprof in the /tmp directory.

jmap -dump:format=b,file=/tmp/heapdump.hprof 12345


Or you could update the Tomcat application servers file to contain the following JAVA_OPTS.



Once the heapdump file has been created, then you can analyze the heap dump.

Add a Comment

We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.

Please enter 01f09 in the box below so that we can be sure you are a human.


Web design by yours truely - me, myself, and I   |   |