title: Free memory from complex objects in Java
body: <p>I try to do my best to explain my question. Maybe it's a bit abstract.</p>
  
  <p>I read some literature about not invoking GC explictly in Java code, finalize method, pointing to null, etc.</p>
  
  <p>I have some large XMLs files (customer invoices). Using Jaxb, the file marshals in a complex Java object. Its attributes are basic types (Integer, BigDecimal, String, etc.) but also class of other complex classes, list of other classes, list of classes with list as attribute, etc.</p>
  
  <p>When I do my stuff with the object, I need to remove it from the memory. Some XML are very large and I can avoid a memory leak or OutOfMemoryError situation.</p>
  
  <p>So, my questions are:</p>
  
  <ul>
  <li>Is it enough to assign big object to null? I read that, if there are soft references, GC will not free the object.</li>
  <li>Should I do a <em>in deep</em> clearing of the object, clearing all list, assigning null to the attributes, etc.?</li>
  <li>What about JaxB (I'm using Java6, so JaxB is built in) and soft references? JaxB is faster than old JibX marshaller, but I don't know if it's worse in memory usage.</li>
  <li>Should I wrap the megacomplex JaxB class with WeakReference or something like this?</li>
  </ul>
  
  <p>Excuse me for mixing Java memory usage concepts, JaxB, etc. I'm studying the stability of a large running process, and the .hprof files evidence that <em>all customers data of all invoices</em> remains in memory.
  Excuse me if it's a simple, basic or rare question.</p>
  
  <p>Thanks in advance</p>