从 Tomcat 6 获取 JVM 上的堆转储 [英] Get a heapdump on JVM from Tomcat 6

查看:31
本文介绍了从 Tomcat 6 获取 JVM 上的堆转储的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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

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

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

谢谢

推荐答案

你应该在tomcat6/bin/catalina.sh的begging(注释后)添加以下行:

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"

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

这篇关于从 Tomcat 6 获取 JVM 上的堆转储的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆