Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I force generation of a JVM crash log file?

Tags:

java

jvm

crash

The log file from a JVM crash contains all sorts of useful information for debugging, such as shared libraries loaded and the complete environment. Can I force the JVM to generate one of these programmatically; either by executing code that crashes it or some other way? Or alternatively access the same information another way?

like image 965
DJClayworth Avatar asked Dec 03 '08 16:12

DJClayworth


People also ask

Where are JVM crash logs?

The JVM crash log location is specified in run. bat on Windows, or run.sh on Linux, and is enabled by default.

What happens when JVM crashes?

When the JRockit JVM crashes, it generates a binary crash file ( . core or . mdmp ). By default, the binary crash file contains a copy of the entire JVM process.

Why does the JVM crash with a core dump?

JVM crash is one of the toughest problem professional Java developers face. In case of a JVM crash, the operating system creates a core dump file which is a memory snapshot of a running process. A core dump is created by the operating system when a fatal or unhandled error like signal or system exception occurs.


2 Answers

You can try throwing an OutOfMemoryError and adding the -XX:+HeapDumpOnOutOfMemoryError jvm argument. This is new as of 1.6 as are the other tools suggested by McDowell. http://blogs.oracle.com/watt/resource/jvm-options-list.html

like image 83
ghbuch Avatar answered Oct 21 '22 03:10

ghbuch


Have a look at the JDK Development Tools, in particular the Troubleshooting Tools for dumping the heap, printing config info, etcetera.

like image 32
McDowell Avatar answered Oct 21 '22 02:10

McDowell