Analysis in SonarQube failed

An analysis failed in SonarQube because of a “java.lang.OutOfMemoryError: Java heap space” error.
We are Analyzing with Sonarqube for gradle, and the local run on is successful but it fails once uploaded to sonarqube. When i check in my background tasks i see the below error

java.lang.OutOfMemoryError: GC overhead limit exceeded
    at java.util.Arrays.copyOf(Arrays.java:3181)
    at java.util.ArrayList.grow(ArrayList.java:261)
    at java.util.ArrayList.ensureExplicitCapacity(ArrayList.java:235)
    at java.util.ArrayList.ensureCapacityInternal(ArrayList.java:227)
    at java.util.ArrayList.add(ArrayList.java:458)
    at com.google.common.collect.Iterators.addAll(Iterators.java:362)
    at com.google.common.collect.Lists.newArrayList(Lists.java:160)
    at com.google.common.collect.Iterables.toCollection(Iterables.java:337)
    at com.google.common.collect.Iterables.toArray(Iterables.java:328)
    at com.google.common.collect.ImmutableSortedSet.copyOf(ImmutableSortedSet.java:356)
    at com.google.common.collect.FluentIterable.toSortedSet(FluentIterable.java:410)
    at org.sonar.server.computation.task.projectanalysis.duplication.Duplication.<init>(Duplication.java:55)
    at org.sonar.server.computation.task.projectanalysis.step.LoadDuplicationsFromReportStep.loadDuplications(LoadDuplicationsFromReportStep.java:86)
    at org.sonar.server.computation.task.projectanalysis.step.LoadDuplicationsFromReportStep.access$100(LoadDuplicationsFromReportStep.java:48)
    at org.sonar.server.computation.task.projectanalysis.step.LoadDuplicationsFromReportStep$1.visitFile(LoadDuplicationsFromReportStep.java:73)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitNode(DepthTraversalTypeAwareCrawler.java:79)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitImpl(DepthTraversalTypeAwareCrawler.java:57)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:39)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitChildren(DepthTraversalTypeAwareCrawler.java:98)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitImpl(DepthTraversalTypeAwareCrawler.java:54)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:39)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitChildren(DepthTraversalTypeAwareCrawler.java:98)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitImpl(DepthTraversalTypeAwareCrawler.java:54)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:39)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitChildren(DepthTraversalTypeAwareCrawler.java:98)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visitImpl(DepthTraversalTypeAwareCrawler.java:54)
    at org.sonar.server.computation.task.projectanalysis.component.DepthTraversalTypeAwareCrawler.visit(DepthTraversalTypeAwareCrawler.java:39)
    at org.sonar.server.computation.task.projectanalysis.step.LoadDuplicationsFromReportStep.execute(LoadDuplicationsFromReportStep.java:78)
    at org.sonar.server.computation.task.step.ComputationStepExecutor.executeSteps(ComputationStepExecutor.java:64)
    at org.sonar.server.computation.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:52)
    at org.sonar.server.computation.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(ReportTaskProcessor.java:73)
    at org.sonar.ce.taskprocessor.CeWorkerImpl.executeTask(CeWorkerImpl.java:134)

Sonarqube - Version 6.7.4
Gradle 4.6
Build time: 2018-02-28 13:36:36 UTC
Revision: 8fa6ce7945b640e6168488e4417f9bb96e4ab46c
Groovy: 2.4.12
Ant: Apache Ant™ version 1.9.9 compiled on February 2 2017
JVM: 1.8.0_191 (Oracle Corporation 25.191-b12)
OS: Linux 3.10.0-862.14.4.el7.x86_64 amd64
classpath “org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:2.6.2”

Hi,

It sounds like you need to grant more memory to the Compute Engine. This doc has some hints under “Troubleshooting/FAQ”. Basically, you’ll use sonar.ce.javaOpts in $SONARQUBE_HOME/conf/sonar.properties to increase the process’ heap allocation. Note that adjustments made here won’t kick in until after you restart the server.

Alternately, the stacktrace tells me the process failed here: LoadDuplicationsFromReportStep. That it, it appears that there are a lot of duplications in the project, and dealing with them bogged the Compute Engine down to the point of collapse. You probably really ought to deal with those duplications, and thus you really want them reported so you can see in SonarQube where they are. But a short term solution might be disabling duplications detection temporarily by adding -Dsonar.cpd.exclusions=**/*.* to your analysis command line. That would give you some breathing room to work out the correct heap size for your CE process before turning duplications detection back on.

 
HTH,
Ann