Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ways how to get heap dump from running tomcat 7

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!

like image 769
emdhie Avatar asked Nov 27 '13 06:11

emdhie


People also ask

How do I get a heap dump on my server?

Start the administrative console. In the navigation pane, click Troubleshooting > Java dumps and cores. Select the server_name for which you want to generate the heap dump. Click Heap dump to generate the heap dump for your specified server.

Where can I find heap dump?

Heap dumps are displayed in the heap dump sub-tab in the main window. You can open binary format heap dump files (. hprof) saved on your local system or use Java VisualVM to take heap dumps of running applications.


2 Answers

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.

like image 160
Taky Avatar answered Sep 28 '22 20:09

Taky


Another way besides the "Dump heap"-Button of jvisualvm is via the JMX-interface. This way even allows you to specify where to store the dump.

connect to tomcat's JMX-server using jconsole or jvisualvm with JMX-plugin. Then got to com.sun.management -> HotSpotDiagnotic -> Operations. Next to dumpHeap fill in the two parameters. From oracle's documentation (see here):

Parameters:

outputFile - the system-dependent filename

live - if true dump only live objects i.e. objects that are reachable from others

Then press dumpHeap and watch the VM freeze for some time while writing the dump.

like image 28
piet.t Avatar answered Sep 28 '22 19:09

piet.t