title: How can I restart JVM on OutOfMemoryError _after_ making a heap dump?
body: <p>I know about the <a href="https://stackoverflow.com/q/542979/260805"><code>-XX:+HeapDumpOnOutOfMemoryError</code></a> JVM parameter. I also know about <a href="https://stackoverflow.com/a/3821180/260805"><code>-XX:OnOutOfMemoryError="cmd args;cmd args"</code></a> and that <code>kill -3 &lt;JVM_PID&gt;</code> will request a heap dump.</p>
  
  <p><strong>Question:</strong> How can I make sure that I, on <code>OutOfMemoryError</code>, first make a full heap dump and <em>then</em> force a restart (or kill) after the dump is done? Is my best bet <code>-XX:OnOutOfMemoryError="kill -3 %p;sleep &lt;time-it-takes-to-dump&gt;;kill -9 %p"</code>?</p>