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 java.lang.OutOfMemoryError: PermGen space
.
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
with the strack trace, I get the following
* 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)
...
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.
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -Xms512m
I have tried the options from Android Studio Gradle Issue: OutOfMemoryError: PermGen space still no luck. I also have been looking at sonarRunner java.lang.OutOfMemoryError: PermGen space.
Hope to get some help on this. Thanks
Try a bigger number than 512m : org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -Xms512m
As @Eugen Martynov mention If you use robolectric gradle plugin, you can specify them as DSL
configuration
The information that I have gathered.
Abdellah gave some insight on the problem and it has to do with the number of total classes created. "you have check https://plumbr.eu/outofmemoryerror/permgen-space "
Eugen Martynov also mentioned the parameter from the robolectric gradle plugin configuration that I can add. Link at https://github.com/robolectric/robolectric-gradle-plugin#configuration-using-dsl
The main problem with my code is that with a limited PermGen space, I was creating a lot of Spy objects in Mockito which seems to be eating up most of the space.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With