Java has a way to collect core dumps which may be helpful in identifying what is causing the JVM to crash.
Linux:
- Enable the collection of core file (complete dump of the memory) by setting ulimit -c to unlimited:
ulimit -c unlimited
- By default, the core dump is created in the current working directory of the process and the name of the core dump file is
core.<pid>
, where pid is the process id of the crashed Java process.
Windows:
NOTE: Crash dump file sizes will be as big as the memory used with your JVM. They will be saved in the same directory as where the JVM was running from. For Java 11, in case of an
OutofMemoryError
, add the argument-XX:+HeapDumpOnOutOfMemoryError
.
To obtain core dumps from:
-
Java version 9 and above, use the following argument before the -agentpath / -agentlib flag:
-XX:+CreateCoredumpOnCrash
-
Java version 8 and before, use the following argument before the -agentpath / -agentlib flag:
-XX:+CreateMinidumpOnCrash
References:
Java 8 Core Dump Troubleshooting Guide
Java 11 Core Dump Troubleshooting Guide
More about the JVM Crash Report:
- Typically named
hs_err_pid<PID number>.log
- The
hs_err
file is typically created in the working directory of the process. - In the event that the file cannot be created in the working directory (insufficient space, permission problem, or other issue), the file is created in the temporary directory for the operating system.
- On Oracle Solaris and Linux operating systems the temporary directory is
/tmp
. - On Windows the temporary directory is specified by the value of the
TMP
environment variable; if that environment variable is not defined, the value of theTEMP
environment variable is used.
- On Oracle Solaris and Linux operating systems the temporary directory is
- The log file location and file name can be overwritten using the
-XX:ErrorFile=<fileName>
java argument. Ex. -java -XX:ErrorFile=/var/log/java/java_error%p.log