当前位置: 动力学知识库 > 问答 > 编程问答 >

java - can't get a dump file using VM Option :HeapDumpOnOutOfMemoryError when OOM exception thrown

问题描述:

Firstly , I use Intelli Idea as IDE to run an application which is designed to cause an OOM Exception .

VM Option:

-Xmx20M -XX:MaxDirectMemorySize=10M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=C:\Users\chao.zhang1\Desktop\aaa.hprof

Application:

import sun.misc.Unsafe;

import java.lang.reflect.Field;

public class DirectMemoryOOM{

private static final int _1MB=1024*1024;

public static void main(String[]args)throws Exception{

Field unsafeField=Unsafe.class.getDeclaredFields()[0];

unsafeField.setAccessible(true);

Unsafe unsafe=(Unsafe)unsafeField.get(null);

while(true){

unsafe.allocateMemory(_1MB);

}

}

}

no dump file exists in directory 'C:\Users\chao.zhang1\Desktop\' after exception thrown.

Secondly , I try another way to avoid the impact of IDE ,I run this command in cmd command line:

java DirectMemoryOOM -Xmx20M -XX:MaxDirectMemorySize=10M -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=C:\Users\chao.zhang1\Desktop\aaa.hprof

still no dump file was created .

The log in console is:

Exception in thread "main" java.lang.OutOfMemoryError

at sun.misc.Unsafe.allocateMemory(Native Method)

at DirectMemoryOOM.main(DirectMemoryOOM.java:12)

updated 2017/2/23 :

today I run into another jvm crash,the intelli idea console output :

#

# A fatal error has been detected by the Java Runtime Environment:

#

# Internal Error (javaCalls.cpp:62), pid=11864, tid=13164

# guarantee(thread->is_Java_thread()) failed: crucial check - the VM thread cannot and must not escape to Java code

#

# JRE version: Java(TM) SE Runtime Environment (7.0_79-b15) (build 1.7.0_79-b15)

# Java VM: Java HotSpot(TM) 64-Bit Server VM (24.79-b02 mixed mode windows-amd64 compressed oops)

# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows

#

# An error report file with more information is saved as:

# E:\apache-tomcat-7.0.69\apache-tomcat-7.0.69\bin\hs_err_pid11864.log

#

# If you would like to submit a bug report, please visit:

# http://bugreport.java.com/bugreport/crash.jsp

#

Disconnected from the target VM, address: '127.0.0.1:58121', transport: 'socket'

I'm wondering if there's anything to do with 'Failed to write core dump. Minidumps are not enabled by default on client versions of Windows',Is it possible that the windows system is not configured correctly for dumping file.

I have also tried to enable Mini-dumps through Advanced System Settings -- > Startup & Recovery -- > Settings -- > Choosing 'small memory dump'. But nothing changed.

Could anyone give some constructive advice? thx!

分享给朋友:
您可能感兴趣的文章:
随机阅读: