How to set Sonarqube Compute Engine Java memory parameters with Environment Variables

  • I’m using Sonarqube 8.2 Docker image

  • I have been receiving java heap errors when users tryo to check in large projects like this:
    java.lang.OutOfMemoryError: Java heap space
    at java.base/java.lang.StringCoding.encodeUTF8_UTF16(Unknown Source)
    at java.base/java.lang.StringCoding.encodeUTF8(Unknown Source)
    at java.base/java.lang.StringCoding.encode(Unknown Source)
    at java.base/java.lang.String.getBytes(Unknown Source)
    at org.sonar.core.hash.SourceHashComputer.addLine(SourceHashComputer.java:37)
    at org.sonar.ce.task.projectanalysis.source.FileSourceDataComputer.compute(FileSourceDataComputer.java:57)
    at org.sonar.ce.task.projectanalysis.source.PersistFileSourcesStep$FileSourceVisitor.visitFile(PersistFileSourcesStep.java:99)

  • I want to Increase the Compute engine Java heap memory from the default 512MB to 1GB using environment variables on the docker run command line.

  • I tried by adding the environment variable to the Docker Run Command like this:
    --env SONAR_CE_JAVAADDITIONALOPTS="-Xmx=1G -Xms=1G"
    and it did not do anything to the heap space.
    How exactly should I specify the JVM memory using the environment variable? I also saw @ceDefaultHeapSize@ referenced in the documentation, but not sure what this is?