addShutdownHook says:
In rare circumstances the virtual machine may abort, that is, stop running without shutting down cleanly. This occurs when the virtual machine is terminated externally, for example with the SIGKILL signal on Unix or the TerminateProcess call on Microsoft Windows. The virtual machine may also abort if a native method goes awry by, for example, corrupting internal data structures or attempting to access nonexistent memory. If the virtual machine aborts then no guarantee can be made about whether or not any shutdown hooks will be run.
When the Java heap runs out of memory and throws an OutOfMemoryError, does that cause the JVM to abort? Do heap OOMs cause native methods to go awry or corrupt internal data structures? Or are heap OOM errors recoverable enough for the shutdown hooks to be executed?