javajenkinssonarqubesonarqube-ops

SonarQube analysis failed java.lang.OutOfMemoryError: Java heap space


I am using SonarQube version 5.3 and using Jenkins version 1.651 to start the Sonar Scanner. I am also using the Sonar Java plugin version 3.11-build4121.

There seems to be a problem the memory. From my debugging I found that a possible solution may be to increase the maximum Java Heap size by using the flag -Xmx in Jenkins. So I attempted this setup:

-Xss1024k -Xmx4096m -XX:MaxPermSize=256m

But without any success since it produces the following errors.

2016.03.03 15:30:52 INFO  [o.s.s.c.t.CeWorkerCallableImpl] Execute task | project=iipaxprod | id=AVM842148nwKD7ip-06E
2016.03.03 15:30:55 INFO  [o.s.s.c.s.ExtractReportStep] Analysis report extracted | compressedSize=49 MB
2016.03.03 15:30:55 INFO  [o.s.s.c.s.ComputationStepExecutor] Extract report | time=2485ms
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep] SonarQube plugins:
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - Java Properties 1.5 (javaProperties)
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - Findbugs 3.3 (findbugs)
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - Java 3.11-build4121 (java)
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - Git 1.1 (scmgit)
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - PMD 2.5 (pmd)
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - Checkstyle 2.4 (checkstyle)
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - SVN 1.2 (scmsvn)
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep] Settings for module: iipaxprod
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.core.id=20160302135558
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.core.startTime=2016-03-02T13:55:58+0100
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.core.version=5.3
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.host.url=http://192.168.40.179:9000/
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.java.source=1.6
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.login=admin
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.password=******
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.permission.template.default=default_template
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.projectBaseDir=/var/lib/jenkins/jobs/iipax-product-Project/workspace
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.projectKey=iipaxprod
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.projectName=iipax-Product
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.projectVersion=1.0
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.qualitygate=1
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.sourceEncoding=ISO-8859-1
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.sources=.
2016.03.03 15:30:55 INFO  [o.s.s.c.s.LogScannerContextStep]   - sonar.working.directory=/var/lib/jenkins/jobs/iipax-product-Project/workspace/.sonar
2016.03.03 15:30:55 INFO  [o.s.s.c.s.ComputationStepExecutor] Log scanner context | time=5ms
2016.03.03 15:30:55 INFO  [o.s.s.c.s.ComputationStepExecutor] Load analysis metadata | time=0ms
2016.03.03 15:30:58 INFO  [o.s.s.c.s.ComputationStepExecutor] Build tree of components | time=2846ms
2016.03.03 15:30:59 INFO  [o.s.s.c.s.ComputationStepExecutor] Validate project | time=79ms
2016.03.03 15:31:00 INFO  [o.s.s.c.s.ComputationStepExecutor] Load debt model | time=1716ms
2016.03.03 15:31:01 INFO  [o.s.s.c.s.ComputationStepExecutor] Load quality profiles | time=291ms
2016.03.03 15:31:01 INFO  [o.s.s.c.s.ComputationStepExecutor] Load Quality gate | time=151ms
2016.03.03 15:31:01 INFO  [o.s.s.c.s.ComputationStepExecutor] Load differential periods | time=35ms
2016.03.03 15:31:01 INFO  [o.s.s.c.s.ComputationStepExecutor] Load inner file and in project duplications | time=311ms
2016.03.03 15:31:01 INFO  [o.s.s.c.d.CrossProjectDuplicationStatusHolderImpl] Cross project duplication is disabled because it's disabled in the analysis report
2016.03.03 15:31:01 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute cross project duplications | time=0ms
2016.03.03 15:31:02 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute size measures | time=431ms
2016.03.03 15:31:18 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute new coverage | time=16647ms
2016.03.03 15:31:18 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute coverage measures | time=47ms
2016.03.03 15:31:19 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute comment measures | time=1000ms
2016.03.03 15:31:21 INFO  [o.s.s.c.s.ComputationStepExecutor] Copy custom measures | time=1997ms
2016.03.03 15:31:22 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute duplication measures | time=915ms
2016.03.03 15:31:25 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute duplication data measures | time=2562ms
2016.03.03 15:31:26 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute language distribution | time=779ms
2016.03.03 15:31:26 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute test measures | time=49ms
2016.03.03 15:31:30 INFO  [o.s.s.c.s.ComputationStepExecutor] Compute complexity measures | time=4833ms
2016.03.03 15:31:30 INFO  [o.s.s.c.s.ComputationStepExecutor] Load measure computers | time=0ms
2016.03.03 15:40:37 INFO  [o.s.s.c.s.ExecuteVisitorsStep]   Execution time for each component visitor:
2016.03.03 15:40:37 INFO  [o.s.s.c.s.ExecuteVisitorsStep]   - LoadComponentUuidsHavingOpenIssuesVisitor | time=5327ms
2016.03.03 15:40:37 INFO  [o.s.s.c.s.ExecuteVisitorsStep]   - IntegrateIssuesVisitor | time=428288ms
2016.03.03 15:40:37 INFO  [o.s.s.c.s.ExecuteVisitorsStep]   - CloseIssuesOnRemovedComponentsVisitor | time=0ms
2016.03.03 15:40:37 INFO  [o.s.s.c.s.ExecuteVisitorsStep]   - SqaleMeasuresVisitor | time=3059ms
2016.03.03 15:40:37 INFO  [o.s.s.c.s.ExecuteVisitorsStep]   - SqaleNewMeasuresVisitor | time=107507ms
2016.03.03 15:40:37 INFO  [o.s.s.c.s.ExecuteVisitorsStep]   - LastCommitVisitor | time=112ms
2016.03.03 15:40:37 INFO  [o.s.s.c.s.ExecuteVisitorsStep]   - MeasureComputersVisitor | time=834ms
2016.03.03 15:40:37 INFO  [o.s.s.c.s.ComputationStepExecutor] Execute component visitors | time=546127ms
2016.03.03 15:46:28 ERROR [o.s.s.c.c.ComputeEngineContainerImpl] Cleanup of container failed
java.lang.OutOfMemoryError: Java heap space
2016.03.03 15:46:28 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AVM842148nwKD7ip-06E
java.lang.OutOfMemoryError: Java heap space
2016.03.03 15:46:28 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Executed task | project=iipaxprod | id=AVM842148nwKD7ip-06E | time=935556ms

I noticed this post: 1 which experiences a similar problem but the problem seems to have been solves once the heap memory size was set to 4096 which it has not for me.

Any suggestions on how I can solve this problem?

Edit-1: spellcorrect.

The entire project is around 760mb in size and 1 million lines of code.


Solution

  • I believe I found the issue which caused this problem - I had been configuring the wrong parameter. I configured the parameter in the Sonar Runner in Jenkins while the issue resided in the SonarQube Web server. Once I edited the parameter in the sonar.properties-file in the SonarQube Server opt/sonar/conf to sonar.web.javaOpts=-Xmx1280m the SonarQube server could analyze the results from the Sonar Runner analysis.