我有一个包含 30K 类的项目模块。 将 Sonar 分析从 ant 脚本迁移到 gradle 插件后,出现 OOM 错误,输出如下:
13:10:36 Out of memory
13:10:36 Total memory: 954M
13:10:36 free memory: 119M13:10:52 Caused by: java.util.concurrent.ExecutionException: java.lang.OutOfMemoryError: GC overhead limit exceeded
13:10:52 at org.sonar.plugins.findbugs.FindbugsExecutor.execute(FindbugsExecutor.java:163)
13:10:52 ... 109 more
13:10:52 Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
13:10:52 at
我们使用以下参数运行 ant 脚本“-Xmx3800m -XX:ReservedCodeCacheSize=128m”
如何为sonarqube gradle插件设置相同的参数?
我尝试在调用 gradle 之前设置以下环境变量
GRADLE_OPTS=-Xmx3800m -XX:ReservedCodeCacheSize=128m
应用正确,但 findbugs 仍然失败并打印“总内存:954M”
我还尝试添加以下属性来减少内存消耗,但没有任何运气
property 'sonar.skipPackageDesign', 'true'
property 'sonar.skipDesign', 'true'
Gradle 版本为 3.5
Sonarqube插件版本为2.5
jdk版本为8u131
最佳答案
我意识到问题出在哪里。
设置 GRADLE_OPTS 是正确的解决方案,但是我也使用了 gradle 守护进程,因此守护进程忽略了这些选项。
我最终通过将 -Dorg.gradle.daemon=false 添加到 GRADLE_OPTS 来禁用守护进程,并且它起作用了。
关于Gradle sonarqube 插件 - 如何为 findbugs 设置内存?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45751473/