从Tomcat 6获取JVM上的heapdump

时间:2013-09-02 18:07:01

标签: tomcat

如何配置tomcat 6,以便如果它因内存不足而崩溃,我会收到堆转储?

我知道jmap可用于在运行时获取它

我可以看到有关如何获取tomcat 7的信息 http://blog.denevell.org/tomcat7-heap-dump-out-of-memory.html

由于

1 个答案:

答案 0 :(得分:4)

您应该在tomcat6/bin/catalina.sh

的开头(评论后)添加以下行
JAVA_OPTS="$JAVA_OPTS -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/dir"

文件: 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.)