To produce a heapdump in the event of an OutOfMemoryError:
-XX:+HeapDumpOnOutOfMemoryError |
Heapdumps can be taken on demand from the new improved jmap tool which uses the built in heapdumper code (unlike the jmap tools in 1.4.2 and 5.0). The histogram option in Java™ 6 also uses a much improved built in mechanism. To manually create a heapdump, use the following command: |
jmap -dump:live,format=b,file= |
To print class histograms, issuing a SIGQUIT - kill -3 [JVM PID] will trigger a class histogram to be written to native_stdout.log:
-XX:+PrintClassHistogram |
SDK 1.5.0_16 or later
To force a heapdump by sending the Java Virtual Machine (JVM) a SIGQUIT - kill -3 [JVM PID]:
-XX:+HeapDumpOnCtrlBreak |
To produce a heapdump in the event of an OutOfMemoryError:
-XX:+HeapDumpOnOutOfMemoryError |
To print class histograms without using jmap, issuing a SIGQUIT - kill -3 [JVM PID] will trigger a class histogram to be written tonative_stdout.log:
-XX:+PrintClassHistogram |
SDK 1.5.0_07 to 1.5.0_15
Note: Manual generation of heapdumps is still not implemented. -XX:+HeapDumpOnCtrlBreak only works on 1.5.0_16 or later.
To produce a heapdump in the event of an OutOfMemoryError:
-XX:+HeapDumpOnOutOfMemoryError |
To print class histograms without using jmap, issuing a SIGQUIT - kill -3 [JVM PID] will trigger a class histogram to be written tonative_stdout.log:
-XX:+PrintClassHistogram |
SDK 1.4.2_12 or later
In 1.4.2_12, Sun implemented a built-in heapdump facility, with a new command line option.
To force a heapdump by sending the Java Virtual Machine (JVM) a SIGQUIT - kill -3 [JVM PID]:
-XX:+HeapDumpOnCtrlBreak |
To produce a heapdump in the event of an OutOfMemoryError:
-XX:+HeapDumpOnOutOfMemoryError |
To print class histograms without using jmap, issuing a SIGQUIT - kill -3 [JVM PID] will trigger a class histogram to be written tonative_stdout.log:
-XX:+PrintClassHistogram |
SDK 1.5.0 GA to 1.5.0_06
SDK 1.4.2_09 to 1.4.2_11
Note: Due to limitations using jmap, the most reliable solution for getting a heapdump will be to upgrade the JDK. Click here for more information.
The jmap executable is contained in the same directory as the Java executable (for example: [path to JDK]/bin), and can be run in a number of ways:
The following produces a heapdump in the current working directory, namedheap.bin:
jmap -heap:format=b [JVM PID] |
jmap -heap:format=b [Java executable] [core file] |
jmap -heap [JVM PID] > heapsummaryfilename |
jmap -histo [JVM PID] > histofilename |
jmap -permstat [JVM PID] > histofilename |