ways how to get heap dump from running tomcat 7

emdhie picture emdhie · Nov 27, 2013 · Viewed 48.8k times · Source

I've tried this Get a heapdump on JVM from Tomcat 6 but it doesn't work for me, Is there other ways to get heap dump from tomcat server? Thanks in advance!

Answer

Taky picture Taky · Nov 27, 2013

The easiest way to get heap dump is to use jmap. On the machine with java process execute jmap command. Example of usage:

jmap -dump:file=/mnt/heapdump_2013-04-01.data 29842

use jps to know java Pid.


Also you can make heap dump via jvisualvm. You can connect to the remote machine via jmx or jstatd. You can make heapdump and store on the remote machine.

To analyze heapdumps can advice you: MAT. Very powerful tool which allow you to quickly understand problems. You can find here good inro to the MAT.


If you don't want to stop application for a long time you can make binary dump(You can use gcore or gdb). And you can use jmap to analyze gdb dump. More information you can read on the atlassian blog. Beware of some issues.