Skip to content

CAUTION: This site hosts draft documentation for the next release. For published content of the latest release, visit www.eclipse.org/openj9/docs

-XX:OnOutOfMemoryError

You can use this Oracle HotSpot option to run commands when a java.lang.OutOfMemoryError is thrown. This option is recognized by Eclipse OpenJ9™ and provided for compatibility.

Syntax

    -XX:OnOutOfMemoryError="<command_string>"

where <command_string> is a command or list of commands to run when a java.lang.OutOfMemoryError occurs.

For example, the following command specifies that the java -version command is run if the Test application throws a java.lang.OutOfMemoryError exception:

java -XX:OnOutOfMemoryError="java -version" Test

If you want to run multiple commands, use semicolons to separate them within <command_string>. For example:

-XX:OnOutOfMemoryError="<java_path> <java_program>; cat file.txt"

The -XX:OnOutOfMemoryError option is equivalent to the following -Xdump option:

-Xdump:tool:events=systhrow,filter=java/lang/OutOfMemoryError,exec=<command_string>

For more information, see -Xdump.