Wednesday, March 24, 2010

Getting Heapdumps on the Solaris

1.6.0

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= [JVM PID]

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]

The following produces a heapdump in the same way as the previous command, but from a core file rather than a running process:

jmap -heap:format=b [Java executable] [core file]

The following produces a summary of the state of the heap, including details of the heap configuration (although this frequently seems to be incorrect):

jmap -heap [JVM PID] > heapsummaryfilename

The following walks the heap and produces a list of all object types, sorted by total size:

jmap -histo [JVM PID] > histofilename

The following produces classloader statistics for the permanent generation. Among other things, the results detail the size and number of classes loaded by each classloader:

jmap -permstat [JVM PID] > histofilename


2 comments:

  1. Hi Rai,
    Sorry about using your tech blog for this but didn't really find any convenient way to reach you.
    It is regarding you 2 BHK flat availability in Brigade Metropolis. If it is still available, I will be interested. You can get in touch with me at madhusudan.sarda@gmail.com or 09886080420.

    I shall appreciate your response even if that is not positive.

    ReplyDelete
  2. Good Post.. very useful.

    Thanks,
    www.wikiconsole.com

    ReplyDelete