Java Profiler 7.5 Help
Solving performance problems
Out of memory error (OutOfMemoryError and -XX:+HeapDumpOnOutOfMemoryError)A memory snapshot is captured automatically on first OutOfMemoryError, if the profiled application runs on Sun Java 6 or newer.
On OutOfMemoryError snapshots are captured via JVM's built-in dumper, which for some reason is off by default. The profiler agent turns it on upon profiled application startup. This adds absolutely no overhead. (Technically, enabling is simply setting the state of a boolean flag. When the first OutOfMemoryError occurs, the JVM dumps the heap to file if the flag is "true").
The corresponding JVM option -XX:+HeapDumpOnOutOfMemoryError is supported not only in Java 6 or newer, but also in Sun Java 1.4.2_12 and newer and in Sun Java 5.0 update 7 and newer. Unfortunately, only since Java 6 it is accessible programmatically. The only way to enable it in pre-Java 6 JVM is to explicitly specify -XX:+HeapDumpOnOutOfMemoryError in the command line of the profiled application.
To check the status, connect to the profiled application and hover over corresponding button as show on the picture below:
The profiler shows the following notification when a snapshot is captured on OutOfMemoryError.
Please note that this approach has several benefits over the capturing snapshot on low memory feature, because it uses the JVM's internal light-weight dumping algorithm. This algorithm is specially designed to work in low memory conditions, where the JVM general purpose profiling interface JVMTI used by profilers may fail due to low resources.
See also Support of HPROF format snapshots.