java JVM 崩溃时,Sun JDK 可以生成核心/堆转储文件吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10944082/
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
Can Sun JDK generate core/heap dump files when JVM crashes?
提问by cheng
Is there anyway to generate core/heap dump file when JVM crashes? Since these files are usually very helpful to find out bugs in code.
当 JVM 崩溃时,是否有生成核心/堆转储文件的方法?由于这些文件通常非常有助于找出代码中的错误。
回答by Tomasz Nurkiewicz
With the following JVM options:
使用以下 JVM 选项:
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath="/tmp"
JVM will dump the content of heap to a file in specified directory. Note that this only happens when OutOfMemoryError
is thrown since dump isn't really needed if JVM crashed due to a different reason.
JVM 会将堆的内容转储到指定目录中的文件中。请注意,这仅在OutOfMemoryError
引发时发生,因为如果 JVM 由于其他原因崩溃,则实际上并不需要转储。
Edit: "Boolean options are turned on with -XX:+ and turned off with -XX:-." docs
编辑:“布尔选项用 -XX:+ 打开,用 -XX:- 关闭。” 文档
回答by Jeffrey Zhao
You can use -XX:HeapDump
JVM options.
您可以使用-XX:HeapDump
JVM 选项。