2

My tomcat application crashed due to memory leak. I want to take the heap dump on the crashed system/jvm. Is it possible? I am using windows/tomcat 6 How?

Michael Dautermann
  • 88,797
  • 17
  • 166
  • 215
java_enthu
  • 2,279
  • 7
  • 44
  • 74

4 Answers4

4

The process does not exists anymore. So there is no heap to dump. Use '-XX:+HeapDumpOnOutOfMemoryError' for the next time.

Julien
  • 1,278
  • 12
  • 26
3

You can get the heap dump at runtime by:

jmap -dump:live,format=b,file=heap.dump

Wallace Wong
  • 279
  • 2
  • 2
2

You can't get a heap dump on a process that is no longer running. Next time you start Tomcat, you're going to have to edit the file in the /bin directory called catalina.sh first so that it contains options to automatically dump the heap if it runs out of memory.

What you need to do is to edit the JAVA_OPTS variable so that contains the JVM options you need. So near the top of the file, after JAVA_OPTS has been created, you need to do something like

JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError"

You can also take heap dumps using JConsole, but in order to do this, you need to know roughly when Tomcat is running out of memory in order for the heap dump to help you diagnose the problem.

Jon
  • 3,510
  • 6
  • 27
  • 32
1

If your application is not responding but the JVM is still limping, you may try using JConsole and trigger a Heap Dump. Search for Heap Dump on this link

Bruno Grieder
  • 28,128
  • 8
  • 69
  • 101