why my exception is not caught?
<p>I have a code which generates the following exception:</p>

<pre><code>Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
    at edu.createArrays(ExhaustivePCFGParser.java:2188)
    at edu.considerCreatingArrays(ExhaustivePCFGParser.java:2158)
    at edu.ExhaustivePCFGParser.parse(ExhaustivePCFGParser.java:339)
    at edu.LexicalizedParserQuery.parse(LexicalizedParserQuery.java:247)
    at edu.LexicalizedParser.apply(LexicalizedParser.java:283)
    at current.Gen.textParsen(Gen.java:162)
    at current.Gen.gen(Gen.java:90)
    at current.Foo.main(Foo.java:120)
</code></pre>

<p>I tried to catch it with the following code:</p>

<pre><code>try {
    // this is the line which cause the exception
    LinkedList&lt;Foo&gt; erg = Gen.gen(rev);
} catch (Exception e) {
    System.out.println("exception: out of memory");
}   
</code></pre>

<p>but when I run the code the exception is not caught. How to solve this?</p>
