I would like to detect an OutOfMemoryError, take a heap dump, and automatically exit the Java program. Say I have the following command-line arguments for my JVM:>
I think this would heavily depend on the actual JVM implementation you are using. I'd like to believe that the JVM in use employs some intelligent ordering, first performing a heap dump than killing the machine. However, in my opinion you should not rely on the order of options.