Search code examples
jenkinsjvmsonarqube

How to avoid "GC overhead limit exceeded"?


Our Sonar Build Environment details as follows:

* SonarQube Server Version - 5.6.7 (64-Bit). 
* Sonar Client Build Operating System – Ubuntu-14.04 (LTS - 64-Bit). 
* Sonar Build machine total RAM: 16-GB.
* Sonar-Scanner- Version - 3.0.3.778.
* sonar-cxx-plugin-0.9.7.jar
* Source Code Language: C++
* Client Machine Java Version: 1.8
* Source Code Size: 62-GB.

Problem:

Through Jenkins sonar-scanner finished successfully (Log as follows).

Jenkins Sonar-Scanner Build Log:

12:24:14 INFO: CPD calculation finished
12:26:35 INFO: Analysis report generated in 136049ms, dir size=1 GB
12:49:25 INFO: Analysis reports compressed in 1369236ms, zip size=385 MB
12:49:43 INFO: Analysis report uploaded in 18811ms
12:49:43 INFO: ANALYSIS SUCCESSFUL, you can browse http://sonarqube-server/dashboard/index/scm.project.4.0
12:49:43 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
12:49:43 INFO: More about the report processing at http://sonarqube-server/api/ce/task?id=AV-af9So2HbsBuSrsvrw
12:50:22 INFO: ------------------------------------------------------------------------
12:50:22 INFO: EXECUTION SUCCESS

Whereas Sonarqube project dashboard shows "No analysis has been performed since creation. The only available section is the configuration." And also under SonarQube Web--> Project--> Administration-->Background Tasks-->Logs shows below errors.

Error:

2017.11.07 13:04:23 ERROR [o.s.s.c.t.CeWorkerCallableImpl] Failed to execute task AV-VUEIr2HbsBuSrsvnY
java.lang.OutOfMemoryError: GC overhead limit exceeded

I have tried the following, still same problem persists.

  1. Tried with SONAR_RUNNER_OPTS option with -Xmx10240m -XX:MaxPermSize=1024m -XX:ReservedCodeCacheSize=128m
  2. Then in sonar-project.properties file I have added sonar.ce.javaOpts=-Xmx1280m & sonar.web.javaOpts=-Xmx1280m
  3. Or still I need to increase the build machine RAM (or) 16-GB is sufficient for 62-GB Code?

Solution

  • You need to upgrade the memory allocated for Compute Engine on the server side not on the scanner side (for this particular issue).

    So on your SonarQube server, update the following parameter :

    sonar.ce.javaOpts=-Xmx2G -Xms128m -XX:+HeapDumpOnOutOfMemoryError -Djava.net.preferIPv4Stack=true
    

    It will allow Compute Engine which will integrate your report to consume 2Gb of memory (by default it's 512Mb).