title: Catching java.lang.OutOfMemoryError?
body: <p><a href="http://java.sun.com/javase/6/docs/api/java/lang/Error.html" rel="noreferrer">Documentation</a> for <code>java.lang.Error</code> says:</p>
  
  <blockquote>
    <p>An Error is a subclass of Throwable that indicates serious problems that a reasonable application should not try to catch</p>
  </blockquote>
  
  <p>But as <code>java.lang.Error</code> is a subclass of <code>java.lang.Throwable</code>, I can catch this type of Throwable.</p>
  
  <p>I understand why it's not a good idea to catch this sort of exception. As far as I understand, if we decide to catch it, the catch handler should not allocate any memory by itself. Otherwise <code>OutOfMemoryError</code> will be thrown again.</p>
  
  <p>So, my question is:</p>
  
  <ol>
  <li>Are there any real world scenarios when catching <code>java.lang.OutOfMemoryError</code> might be a good idea?</li>
  <li>If we decide to catch <code>java.lang.OutOfMemoryError</code>, how can we make sure the catch handler doesn't allocate any memory by itself (any tools or best practices)?</li>
  </ol>