11

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?

DJClayworth
  • 26,349
  • 9
  • 53
  • 79

4 Answers4

8

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

Bill the Lizard
  • 398,270
  • 210
  • 566
  • 880
ghbuch
  • 114
  • 2
  • 1
    See also http://stackoverflow.com/questions/5576672/force-or-generate-jvm-core-dump – jhclark Apr 07 '12 at 15:30
  • That other question seems to be for a core dump that one could send to the JVM implementer, e.g. IBM, rather than an `hs_err_pid*.log`. – PJTraill May 28 '15 at 13:59
2

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

McDowell
  • 107,573
  • 31
  • 204
  • 267
  • Of the tools, [`jstack`](http://docs.oracle.com/javase/6/docs/technotes/tools/share/jstack.html) seems the most promising, in the form `jstack -l -F -m ` (`-F` not needed if process is not hung). This gets you stacks of all threads, in mixed mode (Java and native) and locked synchronisers, even if the process is hung. – PJTraill May 28 '15 at 14:10
  • Or see https://docs.oracle.com/javase/8/docs/technotes/guides/troubleshoot/toc.html for Oracle Java 8 (previous links are 6, but probably not very different content). – PJTraill May 28 '15 at 14:16
1

On Ubuntu 20.04.1 LTS I force core dump on jdk 11 process via

kill -4 <PID>
gmode
  • 3,601
  • 4
  • 31
  • 39
0

I am pretty sure this can be done with the IBM JDK as I was playing around with their stack analyzer some time ago. One option to force the dump would just to cause an outOfMemoryException.

These tools may provide some clues http://www.ibm.com/developerworks/java/library/j-ibmtools1/