Help identifying cause (and remedy) of failed analysis due to OutOfMemoryError

Hello, I’m analyzing a Java multi-project using Sonar 10.7 community.
The analysis is performed by Gradle, using the org.sonarqube Gradle plugin, invoked by Jenkins.
Also from Jenkins I’m using the dependencyCheck step (and dependencyCheckPublisher step) .

At the Jenkins/Gradle side the analysis seems to terminate without issues:

ANALYSIS SUCCESSFUL, you can find the results at: <REDACTED>
Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
More about the report processing at <REDACTED>

When I access the project dashboard on the Sonar server, I see the following:

The last analysis has failed.
See details

Looking at the Error Details on the Background Tasks I have the following:

Error Details
java.lang.OutOfMemoryError: Java heap space
	at java.base/java.util.Arrays.copyOf(Unknown Source)
	at java.base/java.lang.String.<init>(Unknown Source)
	at com.google.protobuf.Utf8$UnsafeProcessor.decodeUtf8(Utf8.java:1347)
	at com.google.protobuf.Utf8.decodeUtf8(Utf8.java:318)
	at com.google.protobuf.CodedInputStream$StreamDecoder.readStringRequireUtf8(CodedInputStream.java:2286)
	at org.sonar.scanner.protocol.output.ScannerReport$Measure$StringValue$Builder.mergeFrom(ScannerReport.java:13914)
	at org.sonar.scanner.protocol.output.ScannerReport$Measure$StringValue$Builder.mergeFrom(ScannerReport.java:13768)
	at com.google.protobuf.CodedInputStream$StreamDecoder.readMessage(CodedInputStream.java:2331)
	at org.sonar.scanner.protocol.output.ScannerReport$Measure$Builder.mergeFrom(ScannerReport.java:14802)
	at org.sonar.scanner.protocol.output.ScannerReport$Measure$1.parsePartialFrom(ScannerReport.java:15656)
	at org.sonar.scanner.protocol.output.ScannerReport$Measure$1.parsePartialFrom(ScannerReport.java:15648)
	at com.google.protobuf.AbstractParser.parsePartialFrom(AbstractParser.java:192)
	at com.google.protobuf.AbstractParser.parsePartialDelimitedFrom(AbstractParser.java:232)
	at com.google.protobuf.AbstractParser.parsePartialDelimitedFrom(AbstractParser.java:238)
	at com.google.protobuf.AbstractParser.parsePartialDelimitedFrom(AbstractParser.java:25)
	at org.sonar.core.util.Protobuf$StreamIterator.doNext(Protobuf.java:192)
	at org.sonar.core.util.Protobuf$StreamIterator.doNext(Protobuf.java:180)
	at org.sonar.core.util.CloseableIterator.bufferNext(CloseableIterator.java:96)
	at org.sonar.core.util.CloseableIterator.hasNext(CloseableIterator.java:87)
	at org.sonar.ce.task.projectanalysis.measure.MeasureRepositoryImpl.loadBatchMeasuresForComponent(MeasureRepositoryImpl.java:108)
	at org.sonar.ce.task.projectanalysis.measure.MeasureRepositoryImpl.getRawMeasure(MeasureRepositoryImpl.java:81)
	at org.sonar.ce.task.projectanalysis.api.measurecomputer.MeasureComputerContextImpl.getMeasure(MeasureComputerContextImpl.java:112)
	at org.sonar.dependencycheck.base.DependencyCheckMeasureComputer.compute(DependencyCheckMeasureComputer.java:53)
	at org.sonar.ce.task.projectanalysis.measure.MeasureComputersVisitor.visitAny(MeasureComputersVisitor.java:65)
	at org.sonar.ce.task.projectanalysis.component.TypeAwareVisitorWrapper.visitAny(TypeAwareVisitorWrapper.java:77)
	at org.sonar.ce.task.projectanalysis.component.VisitorsCrawler.visitNode(VisitorsCrawler.java:114)
	at org.sonar.ce.task.projectanalysis.component.VisitorsCrawler.visitImpl(VisitorsCrawler.java:97)
	at org.sonar.ce.task.projectanalysis.component.VisitorsCrawler.visit(VisitorsCrawler.java:69)
	at org.sonar.ce.task.projectanalysis.step.ExecuteVisitorsStep.execute(ExecuteVisitorsStep.java:51)
	at org.sonar.ce.task.step.ComputationStepExecutor.executeStep(ComputationStepExecutor.java:79)
	at org.sonar.ce.task.step.ComputationStepExecutor.executeSteps(ComputationStepExecutor.java:70)
	at org.sonar.ce.task.step.ComputationStepExecutor.execute(ComputationStepExecutor.java:57)

Can you please help me in understanding, based on the error, where to increase the memory?
Is it sonar.ce.javaOpts the right parameter to update?

Hey there.

Yes, this is the right parameter. Keep in mind this is server-side configuration (to be set in a conf/sonar.properties file or an environment variable if deploying via Docker).

Try bumping it up to 2GB of memory –

sonar.ce.javaOpts=-Xmx2G -Xms128m -XX:+HeapDumpOnOutOfMemoryError

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.