title: Java heap dump & shut down - what order?
body: <p>I would like to detect an <code>OutOfMemoryError</code>, take a heap dump, and automatically exit the Java program. Say I have the following command-line arguments for my JVM:</p>
  
  <pre><code>-XX:OnOutOfMemoryError="kill -9 %p"
  -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/usr/tmp
  </code></pre>
  
  <p>Which happens first? Does the process dump memory and then quit, or the other way around?</p>