1

How do I configure tomcat 6 so that if it crashes from an out of memory error I get a heap dump?

I know jmap can be used to get it while it is running

I can see information for how to to get it for tomcat 7 http://blog.denevell.org/tomcat7-heap-dump-out-of-memory.html

Thanks

More Than Five
  • 9,959
  • 21
  • 77
  • 127

1 Answers1

4

You should add the following line in the begging (after comments) of the tomcat6/bin/catalina.sh:

JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/dir"

The documentation: http://www.oracle.com/technetwork/java/javase/tech/vmoptions-jsp-140102.html

-XX:HeapDumpPath=./java_pid<pid>.hprof  Path to directory or filename for heap dump. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.)
-XX:-HeapDumpOnOutOfMemoryError Dump heap to file when java.lang.OutOfMemoryError is thrown. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.)
Danilo Muñoz
  • 623
  • 1
  • 7
  • 17