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

20,382

Solution 1

With the following JVM options:

-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.

Edit: "Boolean options are turned on with -XX:+ and turned off with -XX:-." docs

Solution 2

You can use -XX:HeapDump JVM options.

Share:
20,382
cheng
Author by

cheng

Updated on July 11, 2022

Comments

  • cheng
    cheng almost 2 years

    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.

  • gerrytan
    gerrytan almost 9 years
    Should be -XX:+HeapDumpOnOutOfMemoryError (with plus symbol) because minus actually turns it off