Fully featured low overhead profiler for Java EE and Java SE platforms.
Easy-to-use performance and memory .NET profiler for Windows, Linux and macOS.
Secure and easy profiling in cloud, containers and clustered environments.
Performance monitoring and profiling of Jenkins, Bamboo, TeamCity, Gradle, Maven, Ant and JUnit.

Out of memory error (OutOfMemoryError and -XX:+HeapDumpOnOutOfMemoryError)

You can capture HPROF snapshot right when your Java application crashes due to an OutOfMemoryError by adding the following JVM argument before starting your application:

-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/path/to/dump/file.hprof

HPROF memory snapshot will be captured automatically on first OutOfMemoryError, if the profiled application runs on Oracle JDK or OpenJDK HotSpot.

The OutOfMemoryError snapshots are captured by JVM's built-in heap dumper, which is disabled by default. JVM option -XX:+HeapDumpOnOutOfMemoryError enables it. However, you do not need to specify this option when profiling your applications, because YourKit Java Profiler agent programmatically enables the dumper upon profiled application startup or when the agent is attached to a running application.

Enabling the dumper is safe and 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.

Anyway, if for some reason you want not to enable the dumper, specify disable_oome_dumper startup option.

To check the status, connect to the profiled application and click trigger toolbar button.

OOME snapshot status

The profiler shows the following notification when a snapshot is captured on OutOfMemoryError.

OOME snapshot event

Please note that this approach has several benefits over the capturing snapshot on high memory usage feature, because it uses the JVM's internal lightweight 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.

YourKit uses cookies and other tracking technologies to improve your browsing experience on our website, to show you personalized content, to analyze our website traffic, and to understand where our visitors are coming from.

By browsing our website, you consent to our use of cookies and other tracking technologies in accordance with the Privacy Policy.