title: JAXB - unmarshal OutOfMemory: Java Heap Space
body: <p>I'm currently trying to use JAXB to unmarshal an XML file, but it seems that the XML file is too large (~500mb) for the unmarshaller to handle. I keep getting <code>java.lang.OutOfMemoryError: Java heap space</code> @ </p>
  
  <pre><code>Unmarshaller um = JAXBContext.newInstance("com.sample.xml");
  Export e = (Export)um.unmarhsal(new File("SAMPLE.XML"));
  </code></pre>
  
  <p>I'm guessing this is becuase it's trying to open the large XML file as an object, but the file is just too large for the java heap space.</p>
  
  <p>Is there any other more 'memory efficient' method of parsing large XML files ~ 500mb? Or perhaps an unmarshaller property that may help me handle the large XML file?</p>
  
  <p>Here's what my XML looks like</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8" standalone="yes"?&gt;
  &lt;!-- --&gt;
  &lt;Export xmlns="wwww.foo.com" xmlns:xsi="www.foo1.com" xsi:schemaLocation="www.foo2.com/.xsd"&gt;
  &lt;!--- ---&gt;
  &lt;Origin ID="foooo" /&gt;
  &lt;!---- ----&gt;
  &lt;WorkSets&gt;
     &lt;WorkSet&gt;
        &lt;Work&gt;
           .....
        &lt;Work&gt;
           ....
        &lt;Work&gt;
        .....
     &lt;/WorkSet&gt;
     &lt;WorkSet&gt;
        ....
     &lt;/WorkSet&gt;
  &lt;/WorkSets&gt;
  </code></pre>
  
  <p>I'd like to unmarshal at the WorkSet level, still being able to read through all of the work for each WorkSet.</p>