title: Java Threads for Memory Management
body: <p>I have an application that performs a very sequential set of discrete tasks.</p>
  
  <p>My problem is that one of the first tasks consumes a large amount of memory, and despite eliminating object references and invoking the garbage collector, only about half the memory is essentially freed. This impacts later tasks. The problem is also that I want to temporarily grant the JVM a large heap to efficiently manage the first task but I don't want this to stick around till the GC decides it's efficient to free the rest.</p>
  
  <p>I had the idea of executing the memory-intensive task inside thread; the new child thread uses the parent JVM (no surprise here), but there appears to be no change in the memory management.</p>
  
  <p>How does Java handle Thread memory? Is there a simple way to create a child heap for the subthread that can be dumped after the thread has finished?</p>
  
  <p>As an addendum, here's what I actually want to do:</p>
  
  <ol>
  <li>Setup a Neo4j graph database (I'm creating several million nodes, properties and relationships, along with numerous indexes) [memory intensive]</li>
  <li>Perform queries on the graph database</li>
  </ol>