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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 03:10:40  来源:igfitidea点击:

Can Sun JDK generate core/heap dump files when JVM crashes?

javacoredumpjvm-crash

提问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 OutOfMemoryErroris 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:HeapDumpJVM options.

您可以使用-XX:HeapDumpJVM 选项