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?
4 Answers
The process does not exists anymore. So there is no heap to dump. Use '-XX:+HeapDumpOnOutOfMemoryError' for the next time.

- 1,278
- 12
- 26
-
It means I need to wait till next crash :( – java_enthu Mar 27 '12 at 14:01
-
Yes, it does. There is no getting around that. – Jon Mar 27 '12 at 14:42
You can get the heap dump at runtime by:
jmap -dump:live,format=b,file=heap.dump

- 279
- 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.

- 3,510
- 6
- 27
- 32
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

- 28,128
- 8
- 69
- 101