title: GradleWorkerMain OutOfMemoryError
body: <p>I'm trying to gradling ant based (Netbeans RCP) project and finding the strange gradle behavior.
  I made some observation with profiler and get the next results.</p>
  <h2>Environment configuration</h2>
  <pre><code>Gradle 1.9
  Build time:   2013-11-19 08:20:02 UTC
  Build number: none
  Revision:     7970ec3503b4f5767ee1c1c69f8b4186c4763e3d
  
  Groovy:       1.8.6
  Ant:          Apache Ant(TM) version 1.9.2 compiled on July 8 2013
  Ivy:          2.2.0
  JVM:          1.7.0_45 (Oracle Corporation 24.45-b08)
  OS:           Linux 2.6.32-431.el6.x86_64 amd64
  
  $ echo $GRADLE_OPTS
  -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -Xms256m -Xmx2048m
  $ echo $ANT_OPTS
  -XX:+UnlockCommercialFeatures -XX:+FlightRecorder -Xms256m -Xmx2048m
  </code></pre>
  <ul>
  <li><p><a href="http://pastebin.com/DwhpHTiZ" rel="nofollow noreferrer">build.gradle</a> - contains import for ant tasks (clean, build, unit tests)</p>
  </li>
  <li><p><a href="http://pastebin.com/4BJka5Ds" rel="nofollow noreferrer">settings.gradle</a></p>
  </li>
  </ul>
  <h2>Running imported ant junit test tasks with gradle</h2>
  <p>Gradle fork separate jvm for this and run JUnitTestRunner with different Xmx value, ignoring
  $GRADLE_OPTS and $ANT_OPTS values</p>
  <p>No idea how gradle define Xmx size for each JUnitTestRunner ant task.
  It works fine, as a GC during each tasks.
  All unit tests for all modules passed without errors.</p>
  <h2>Running gradle build tasks for the same modules</h2>
  <p>Gradle knows previous build results and immediately starting junit tests for untested module.
  You may see the output <a href="http://pastebin.com/FBVctHgB" rel="nofollow noreferrer">here</a>!
  Gradle fork separate jvm (ignoring $GRADLE_OPTS value) for this and run GradleWorkerMain.
  And this jvm has 1.42GB Xmx and 500 MB
  immediately occupied! Then used memory size reaches 1.5GB.
  Then GC for unknown reason can't free memory and throw</p>
  <p>-<a href="http://pastebin.com/6CXepkP4" rel="nofollow noreferrer">java.lang.OutOfMemoryError: GC overhead limit exceeded</a></p>
  <p>-<a href="http://pastebin.com/FBVctHgB" rel="nofollow noreferrer">console log</a></p>
  <h2>Questions</h2>
  <ul>
  <li><p>why ant task max Xmx size in 540 MB enough for testing while for GradleWorkerMain 1.5GB is not enough?</p>
  </li>
  <li><p>I'm new to gradle so may be my <a href="http://pastebin.com/DwhpHTiZ" rel="nofollow noreferrer">build.gradle</a> contains errors that result
  in such GradleWorkerMain strange behavior. Is it true? What possible solution is?</p>
  </li>
  <li><p>how to provide for GradleWorkerMain jvm more Xmx?</p>
  </li>
  </ul>