Android Robolectric Gradle - java.lang.OutOfMemoryError: PermGen space
Android Robolectric Gradle - java.lang.OutOfMemoryError: PermGen space
我有一个 android 项目设置和 robolectric 测试,现在总共有大约 2084 个单元测试。但是由于 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
通过 strack 跟踪,我得到以下内容
* 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)
...
在我的 `gradle.properties 根目录和我的模块目录中,我尝试放置以下内容但没有任何效果。我仍然遇到内存不足的问题。
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -Xms512m
我已经尝试了 Android Studio Gradle Issue: OutOfMemoryError: PermGen space still no luck. I also have been looking at sonarRunner java.lang.OutOfMemoryError: PermGen space 中的选项。
希望得到一些帮助。谢谢
尝试大于 512m 的数字:org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -Xms512m
编辑
如@Eugen Martynov 所述,如果您使用 robolectric gradle 插件,您可以将它们指定为 DSL
configuration
我收集到的信息。
Abdellah 对这个问题给出了一些见解,它与创建的 类 总数有关。
"you have check https://plumbr.eu/outofmemoryerror/permgen-space "
Eugen Martynov 还提到了我可以添加的 robolectric gradle 插件配置中的参数。 Link 在 https://github.com/robolectric/robolectric-gradle-plugin#configuration-using-dsl
我的代码的主要问题是使用有限的 PermGen space,我在 Mockito 中创建了很多 Spy 对象,这似乎占用了大部分 space。
我有一个 android 项目设置和 robolectric 测试,现在总共有大约 2084 个单元测试。但是由于 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
通过 strack 跟踪,我得到以下内容
* 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)
...
在我的 `gradle.properties 根目录和我的模块目录中,我尝试放置以下内容但没有任何效果。我仍然遇到内存不足的问题。
org.gradle.jvmargs=-Xmx1024m -XX:MaxPermSize=512m -Xms512m
我已经尝试了 Android Studio Gradle Issue: OutOfMemoryError: PermGen space still no luck. I also have been looking at sonarRunner java.lang.OutOfMemoryError: PermGen space 中的选项。
希望得到一些帮助。谢谢
尝试大于 512m 的数字:org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=1024m -Xms512m
编辑
如@Eugen Martynov 所述,如果您使用 robolectric gradle 插件,您可以将它们指定为 DSL
configuration
我收集到的信息。
Abdellah 对这个问题给出了一些见解,它与创建的 类 总数有关。 "you have check https://plumbr.eu/outofmemoryerror/permgen-space "
Eugen Martynov 还提到了我可以添加的 robolectric gradle 插件配置中的参数。 Link 在 https://github.com/robolectric/robolectric-gradle-plugin#configuration-using-dsl
我的代码的主要问题是使用有限的 PermGen space,我在 Mockito 中创建了很多 Spy 对象,这似乎占用了大部分 space。