SonarQube 5.6.4 中的 OutOfMemoryError

OutOfMemoryError in SonarQube 5.6.4

我正在尝试分析一个(大型,约 90 万行代码)C# 项目,该项目在早期版本的 SonarQube (5.4) 中运行良好但现在失败了(请参阅下面的堆栈跟踪)。

我尝试为 ComputeEngine 分配更多内存(在 5.4 中这似乎与主应用程序共享资源)但仍然出现相同的错误:

sonar.ce.javaOpts=-Xmx1G -Xms512m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true

(来自:$SONAR_HOME\conf\sonar.properties

有什么建议我需要做什么吗?

堆栈跟踪:

2016.12.28 12:13:18 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute duplication measures | time=338ms
2016.12.28 12:15:51 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AVlFV-iVMj2WmfjY00WT
java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOfRange(Arrays.java:3664) ~[na:1.8.0_111]
    at java.lang.String.<init>(String.java:207) ~[na:1.8.0_111]
    at java.lang.StringBuilder.toString(StringBuilder.java:407) ~[na:1.8.0_111]
    at org.sonar.server.computation.step.DuplicationDataMeasuresStep$DuplicationVisitor.createXmlDuplications(DuplicationDataMeasuresStep.java:104) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.step.DuplicationDataMeasuresStep$DuplicationVisitor.computeDuplications(DuplicationDataMeasuresStep.java:84) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.step.DuplicationDataMeasuresStep$DuplicationVisitor.visitFile(DuplicationDataMeasuresStep.java:79) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitNode(DepthTraversalTypeAwareCrawler.java:79) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitImpl(DepthTraversalTypeAwareCrawler.java:51) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:39) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitChildren(DepthTraversalTypeAwareCrawler.java:98) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitImpl(DepthTraversalTypeAwareCrawler.java:54) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:39) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitChildren(DepthTraversalTypeAwareCrawler.java:98) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitImpl(DepthTraversalTypeAwareCrawler.java:54) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:39) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitChildren(DepthTraversalTypeAwareCrawler.java:98) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visitImpl(DepthTraversalTypeAwareCrawler.java:54) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:39) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.step.DuplicationDataMeasuresStep.execute(DuplicationDataMeasuresStep.java:66) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.step.ComputationStepExecutor.executeSteps(ComputationStepExecutor.java:64) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:52) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.taskprocessor.report.ReportTaskProcessor.process(ReportTaskProcessor.java:75) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.executeTask(CeWorkerCallableImpl.java:81) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.call(CeWorkerCallableImpl.java:56) ~[sonar-server-5.6.4.jar:na]
    at org.sonar.server.computation.taskprocessor.CeWorkerCallableImpl.call(CeWorkerCallableImpl.java:35) ~[sonar-server-5.6.4.jar:na]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_111]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) ~[na:1.8.0_111]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) ~[na:1.8.0_111]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access1(ScheduledThreadPoolExecutor.java:180) ~[na:1.8.0_111]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) ~[na:1.8.0_111]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[na:1.8.0_111]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[na:1.8.0_111]
2016.12.28 12:15:51 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Executed task | project=xxx.xxx.xxx.xxx.xxx | type=REPORT | id=AVlFV-iVMj2WmfjY00WT | time=244116ms

$SONAR_HOME\conf\sonar.properties 中设置 sonar.ce.javaOpts=-Xmx3G -Xms512m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true 成功了。