SonarScanner fails for some repositories with JRE Memory limitation

Must-share information (formatted with Markdown):

  • which versions are you using
    SonarQube 6.7.3

We are facing problem with sonar analysis for some large git repositories.

21:26:59 Java HotSpot™ 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000724b00000, 610271232, 0) failed; error=‘Cannot allocate memory’ (errno=12)
21:26:59 #
21:26:59 # There is insufficient memory for the Java Runtime Environment to continue.
21:26:59 # Native memory allocation (mmap) failed to map 610271232 bytes for committing reserved memory.
21:26:59 # An error report file with more information is saved as:
21:26:59 # /home/desjensl/jenkins_slave/metamodeling-jenkins/vihlatrigger01/p002/workspace/DES-DMF_metagen_sonar_test/hs_err_pid44435.log
21:27:00 WARN: Unable to locate ‘report-task.txt’ in the workspace. Did the SonarScanner succedeed?
21:27:00 ERROR: SonarQube scanner exited with non-zero code: 1
21:27:00 Finished: FAILURE

We have tried increasing the heap as scanner arguments with no positive results :

-Xmx4000m -XX:MaxPermSize=4000m

Should we look at server config as well? Also what else can we configure in sonar scanner

This error

There is insufficient memory for the Java Runtime Environment to continue.

Tends to indicate there’s simply not enough memory on the machhine (nothing about running out of heap memory, it can’t allocate it in the first place!). You may want to check the amount of free memory available.

If you do need to adjust the heap size, you’ll want to provide such -Xmx and -Xms arguments to a SONAR_SCANNER_OPTS environment variable, not as analysis arguments.

thanks for the response.

We have increased the RAM by 4GB, still we same the error. Although this time, we donot see the error at the scanner, but the report processing (we can see the failure on the “background Tasks” Page).

Then it’s a very different error! Time to adjust the memory available to your Compute Engine (adjusting the heap values for sonar.ce.javaOpts in your $SONARQUBE_HOME/conf/sonar.propeties file.

I would suggest doubling the maximum value until you no longer receive the error.

I’d also suggest you start to eye an upgrade to SonarQube v7.9 LTS, currently the minimum supported version of SonarQube.