Java 将 HeapDumpOnOutOfMemoryError 参数用于 JBoss 的堆转储
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/542979/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using HeapDumpOnOutOfMemoryError parameter for heap dump for JBoss
提问by
I was told I can add the -XX:+HeapDumpOnOutOfMemoryError
parameter to my JVM start up options to my JBoss start up script to get a heap dump when we get an out of memory error in our application. I was wondering where this data gets dumped? Is it just to the console, or to some log file? If it's just to the console, what if I'm not logged into the Unix server through the console?
有人告诉我,我可以将-XX:+HeapDumpOnOutOfMemoryError
参数添加到我的 JBoss 启动脚本的 JVM 启动选项中,以便在应用程序出现内存不足错误时获取堆转储。我想知道这些数据在哪里转储?它只是到控制台,还是到一些日志文件?如果只是到控制台,如果我没有通过控制台登录到Unix服务器怎么办?
采纳答案by Matt Solnit
Here's what Oracle's documentationhas to say:
以下是Oracle 的文档必须说的内容:
By default the heap dump is created in a file called java_pid.hprof in the working directory of the VM, as in the example above. You can specify an alternative file name or directory with the
-XX:HeapDumpPath=
option. For example-XX:HeapDumpPath=/disk2/dumps
will cause the heap dump to be generated in the/disk2/dumps
directory.
默认情况下,堆转储是在一个名为JAVA_文件中创建PID.hprof在虚拟机的工作目录,如上面的例子。您可以使用该
-XX:HeapDumpPath=
选项指定备用文件名或目录。例如-XX:HeapDumpPath=/disk2/dumps
会导致在/disk2/dumps
目录中生成堆转储。
回答by Swaminathan Krishnamoorthi
You can view this dump from the UNIX console.
您可以从 UNIX 控制台查看此转储。
The path for the heap dump will be provided as a variable right after where you have placed the mentioned variable.
堆转储的路径将在您放置上述变量的位置之后作为变量提供。
E.g.:
例如:
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=${DOMAIN_HOME}/logs/mps"
You can view the dump from the console on the mentioned path.
您可以在提到的路径上从控制台查看转储。
回答by B5A7
I found it hard to decipher what is meant by "working directory of the VM". In my example, I was using the Java Service Wrapper program to execute a jar - the dump files were created in the directory where I had placed the wrapper program, e.g. c:\myapp\bin. The reason I discovered this is because the files can be quite large and they filled up the hard drive before I discovered their location.
我发现很难破译“VM 的工作目录”的含义。在我的示例中,我使用 Java Service Wrapper 程序来执行 jar - 转储文件是在我放置包装程序的目录中创建的,例如 c:\myapp\bin。我发现这一点的原因是这些文件可能非常大,并且在我发现它们的位置之前它们已经填满了硬盘驱动器。
回答by Swapnil Chaudhari
If you are not using "-XX:HeapDumpPath" option then in case of JBoss EAP/As by default the heap dump file will be generated in "JBOSS_HOME/bin" directory.
如果你没有使用 "-XX:HeapDumpPath" 选项,那么在 JBoss EAP/As 默认情况下,堆转储文件将在 "JBOSS_HOME/bin" 目录中生成。