Java heap dump & shut down - what order?

前端 未结 5 1337
暖寄归人
暖寄归人 2021-02-07 08:35

I would like to detect an OutOfMemoryError, take a heap dump, and automatically exit the Java program. Say I have the following command-line arguments for my JVM:

5条回答
  •  鱼传尺愫
    2021-02-07 09:00

    You shall use

    ExitOnOutOfMemoryError or CrashOnOutOfMemoryError

    and

    HeapDumpOnOutOfMemoryError

    OpenJDK JVM (Hotspot) at first takes the heap dump and then crashes out or exits as opted for.

    To get a clearer understanding you may refer to JVM source file taking care of this particular logic.

    https://hg.openjdk.java.net/jdk8u/jdk8u/hotspot/file/8641949eb21f/src/share/vm/utilities/debug.cpp

提交回复
热议问题