问题描述
我正在尝试设置我正在使用的服务器的 JVM,因此它会在发生 OOME 时将堆转储到文件中.
我知道我必须将此选项 -XX:-HeapDumpOnOutOfMemoryError
添加到 JVM 参数中的某处,但我不知道如何执行此操作.
仅供参考,我可以通过 PuTTY 访问服务器,所以我正在寻找执行此操作的命令行方式.
我使用的 JVM 是 OpenJDK64 位服务器 VM.
我不知道这是否相关,但该应用程序是一个战争文件.
PS : ps -ef|grep javatomcat 23837 1 0 Mar25 ?00:03:46/usr/lib/jvm/jre/bin/java -classpath :/usr/share/tomcat6/bin/bootstrap.jar:/usr/share/tomcat6/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat6/temp -Djava.util.logging.config.file=/usr/share/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.bootstrap 启动
我发现了一些东西,如果我错了,请纠正我:因为我使用的是 Tomcat,所以我决定在 tomcat.conf 文件中添加这些行:
JAVA_OPTS=-XX:-HeapDumpOnOutOfMemoryError
JAVA_OPTS=-XX:HeapDumpPath=/root/dump
JAVA_OPTS=-Xmx20m
你怎么看?
HotSpot VM 中的这个选项 选项.我认为它在 OpenJDK VM 中是一样的,但如果不是,请告诉我.
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=
您也可以使用 jmap 手动生成内存映射,如果您知道进程 ID:
jmap -J-d64 -dump:format=b,file=
您可以使用 JHat 来分析转储.>
jhat
I am trying to set the JVM of the server I am working on, so it dumps a heap to file when an OOME occurs.
I know I have to add this option -XX:-HeapDumpOnOutOfMemoryError
to the JVM arguments somewhere, but I can't figure how to do this.
FYI, I can access the server through PuTTY, so I am looking for a command line way of doing this.
The JVM I am using is OpenJDK64-Bit Server VM.
I don't know if that's relevant, but the application is a war file.
PS : ps -ef|grep java
tomcat 23837 1 0 Mar25 ? 00:03:46 /usr/lib/jvm/jre/bin/java -classpath :/usr/share/tomcat6/bin/bootstrap.jar:/usr/share/tomcat6/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/cache/tomcat6/temp -Djava.util.logging.config.file=/usr/share/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start
EDIT :
I found something, correct me if I'm wrong : since I am using Tomcat, I decided to add these lines in the tomcat.conf file:
JAVA_OPTS=-XX:-HeapDumpOnOutOfMemoryError
JAVA_OPTS=-XX:HeapDumpPath=/root/dump
JAVA_OPTS=-Xmx20m
What do you think ?
This option from the HotSpot VM options. I would think it'd be the same in the OpenJDK VM but let me know if it's not.
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<path to dump file>
You can also manually generate a memory map using jmap if you know the process id:
jmap -J-d64 -dump:format=b,file=<path to dump file> <jvm pid>
You can use JHat to analyze the dump.
jhat <path to dump file>
这篇关于设置 JVM 以在抛出 OutOfMemoryError 时转储堆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!