cheng
cheng

Reputation: 2146

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

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.

Upvotes: 10

Views: 24101

Answers (2)

Tomasz Nurkiewicz
Tomasz Nurkiewicz

Reputation: 340933

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

Upvotes: 18

Jeffrey Zhao
Jeffrey Zhao

Reputation: 5023

You can use -XX:HeapDump JVM options.

Upvotes: 2

Related Questions