当本机分配失败时,Java不会创建heapdump

Rak*_*lik 5 java java-native-interface out-of-memory native-code heap-dump

使用参数-XX:+ HeapDumpOnOutOfMemoryError启动JVM.但它并没有在outofmemory上创造堆积.

当本地分配失败时,Java不会创建heapdump吗?

以下是日志:

# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 1184288 bytes for Chunk::new
# An error report file with more information is saved as:
# D:\product\bin\hs_err_pid5876.log
java.lang.OutOfMemoryError
Run Code Online (Sandbox Code Playgroud)

- 编辑 -

最大堆大小设置为4GB,系统RAM大小为16GB,当内存不足时,它使用> 11GB(由Windows任务管理器显示).

从与@ alain.janinm的讨论....我想我可以得出结论,JVm甚至没有足够的内存来生成heapdump.

那么,创建heapdump是否有可能导致JVM使用那么多系统内存

ala*_*inm 3

根据错误 ajava.lang.OutOfMemoryError已抛出。堆栈跟踪的其余部分表明它发生在本机堆中。因此,分配失败是在 JNI 或本机方法中检测到的,而不是在 Java VM 代码中检测到的。(来自内存泄漏故障排除

这可能就是没有创建堆转储的原因。根据XX:+HeapDumpOnOutOfMemoryError 文档

-XX:+HeapDumpOnOutOfMemoryError 命令行选项告诉 HotSpot VM 在无法满足 Java 堆或永久代的分配时生成堆转储。

由于分配在本机堆中失败,而不是在 Java 堆中失败,因此未创建转储。