title: Android Robolectric Gradle - java.lang.OutOfMemoryError: PermGen space
body: <p>I have an android project setup with robolectric tests with a total of around 2084 unit tests right now. But I have been running into issues adding more tests because of the <code>java.lang.OutOfMemoryError: PermGen space</code>. </p>
  
  <pre><code>objc[11380]: Class JavaLaunchHelper is implemented in both /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/bin/java and /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home/jre/lib/libinstrument.dylib. One of the two will be used. Which one is undefined.
  java.lang.OutOfMemoryError: PermGen space                        
  Exception in thread "Test worker" java.lang.OutOfMemoryError: PermGen space
  Exception in thread "Thread-0" java.lang.OutOfMemoryError: PermGen space
  :app:testDebug FAILED   
  </code></pre>
  
  <p>with the strack trace, I get the following</p>
  
  <pre><code>* Exception is:
  org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:testDebug'.
          at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
          at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
          at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
          at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
          at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
          at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java
  ...
  Caused by: org.gradle.process.internal.ExecException: Process 'Gradle Test Executor 1' finished with non-zero exit value 1
      at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:365)
      at org.gradle.process.internal.DefaultWorkerProcess.waitForStop(DefaultWorkerProcess.java:161)
      at org.gradle.api.internal.tasks.testing.worker.ForkingTestClassProcessor.stop(ForkingTestClassProcessor.java:86)
      at org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor.endBatch(RestartEveryNTestClassProcessor.java:60)
      at org.gradle.api.internal.tasks.testing.processors.RestartEveryNTestClassProcessor.stop(RestartEveryNTestClassProcessor.java:54)
      at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
  ...
  </code></pre>
  
  <p>In my `gradle.properties in the root directory and my module directory, I tried putting the following and nothing worked. I still get the out of memory problem.</p>
  
  <pre><code>org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -Xms512m
  </code></pre>
  
  <p>I have tried the options from <a href="http://www.answerques.com/smm1gQqgeXgS/android-studio-gradle-issue-outofmemoryerror-permgen-space" rel="nofollow noreferrer">Android Studio Gradle Issue: OutOfMemoryError: PermGen space</a> still no luck. I also have been looking at <a href="https://stackoverflow.com/questions/18499829/sonarrunner-java-lang-outofmemoryerror-permgen-space">sonarRunner java.lang.OutOfMemoryError: PermGen space</a>.</p>
  
  <p>Hope to get some help on this. Thanks</p>