- 
                Notifications
    
You must be signed in to change notification settings  - Fork 98
 
Handling of OnOutOfMemoryError switches in the SapMachine
        Andreas Steiner edited this page Jul 25, 2025 
        ·
        3 revisions
      
    Handling of ExitOnOutOfMemoryError, CrashOnOutOfMemoryError, OnOutOfMemoryError and HeapDumpOnOutOfMemoryError in SapMachine differs from upstream OpenJDK.
Behaviorial changes to stock OpenJDK highlighted with italics:
- 
ExitOnOutOfMemoryError- also works for thread exhaustion OOMs
 - also works for direct memory OOMs with system property -Djdk.nio.reportErrorOnDirectMemoryOom=true. Since 17.0.15/21.0.7
 - prints stack to stdout
 - prints "Terminating due to java.lang.OutOfMemoryError" to stdout
 - Exits the VM
 
 - 
CrashOnOutOfMemoryError- also works for thread exhaustion OOMs
 - also works for direct memory OOMs with system property -Djdk.nio.reportErrorOnDirectMemoryOom=true. Since 17.0.15/21.0.7
 - prints stack to stdout
 - Writes an error report (hs_err_pid..)
 - prints "Aborting due to java.lang.OutOfMemoryError" to stdout
 - exits the VM
 - will NOT write a core file unless 
+CreateCoredumpOnCrashwas explicitly specified on the command line 
 - 
HeapDumpOnOutOfMemoryError- also works for thread exhaustion OOMs
 - also works for direct memory OOMs with system property -Djdk.nio.reportErrorOnDirectMemoryOom=true. Since 17.0.15/21.0.7
 - prints stack to stdout
 - generates heap dump
 
 - 
OnOutOfMemoryError=command- also works for thread exhaustion OOMs (but note that whatever resource exhaustion caused thread creation errors may cause the subsequent fork for 
commandto fail as well) - prints stack to stdout
 - invokes the given command
 
 - also works for thread exhaustion OOMs (but note that whatever resource exhaustion caused thread creation errors may cause the subsequent fork for 
 
Notes:
- Avoiding core file creation with 
CrashOnOutOfMemoryErroris intentional.CrashOnOutOfMemoryErroris by default tuned to shut the VM down with a minimum of fuzz while still giving us a useful error report. If a core file is wanted for post analysis, specify-XX:+CreateCoreDumpOnCrash. - For thread creation errors, 
xxxOnOutOfMemoryErrorswitches are handled before the JVMTI ResourceExhausted event is posted. This means that JVMTI agents monitoring this event (e.g. CloundFoundry'sjvmkill) may not get invoked. This is intentional. - The SapMachine-specific flag 
ExitVMOnOutOfMemoryError(note the "VM" in the name, not to be confused withExitOnOutOfMemoryError) is an alias toCrashOnOutOfMemoryErrorand provided for backward compatibility reasons.