I know about the -XX:+HeapDumpOnOutOfMemoryError JVM parameter. I also know about -XX:OnOutOfMemoryError=\"cmd args;cmd args\" and that kill -3
will
If you just want to shutdown you can use one of the following parameters:
-XX:+ExitOnOutOfMemoryError
-XX:+CrashOnOutOfMemoryError
The VM arguments were added in Java version 8u92, see the release notes.
ExitOnOutOfMemoryError
When you enable this option, the JVM exits on the first occurrence of an out-of-memory error. It can be used if you prefer restarting an instance of the JVM rather than handling out of memory errors.CrashOnOutOfMemoryError
If this option is enabled, when an out-of-memory error occurs, the JVM crashes and produces text and binary crash files.
Enhancement Request: JDK-8138745 (parameter naming is wrong though JDK-8154713, ExitOnOutOfMemoryError
instead of ExitOnOutOfMemory
)