Scanning crashes with 'java.lang.OutOfMemoryError: Java heap space'

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
sonarqube-9.4.0.54424
sonar-scanner-4.7.0.2747-linux
  • what are you trying to achieve
    Running sonar scanner to scan the Django application.

  • what have you tried so far to achieve this.
    We installed server and scanner on the same development server with capacity of 4GB Memory, but when I ran scanner I see the result and ‘top’ command shows 30% of memory consumed during scanning but why this has to be failed. Do I need to allocate more memory to JVM? Please advice?

NFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 2:35.014s
INFO: Final Memory: 53M/180M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarScanner execution
java.lang.OutOfMemoryError: Java heap space
        at org.sonar.scanner.protocol.output.ScannerReport$SyntaxHighlightingRule$Builder.buildPartial(ScannerReport.java:31401)
        at org.sonar.scanner.protocol.output.ScannerReport$SyntaxHighlightingRule$Builder.build(ScannerReport.java:31392)
        at org.sonar.scanner.sensor.DefaultSensorStorage.lambda$store$1(DefaultSensorStorage.java:286)
        at org.sonar.scanner.sensor.DefaultSensorStorage$$Lambda$1186/0x0000000100970c40.apply(Unknown Source)

Best regards,
~Ram

Hi,

Ideally, the server and scanner will be on different boxes.

Regarding heap space, the docs should help.

 
Ann

Thank you, Ann. Before installing a server and a scanner on our server, we reviewed the requirements from the following page and found that we selected the right resourced server.

https://docs.sonarqube.org/latest/requirements/requirements/

and we did not see a separate resources requirement for scanner alone.

Since we are blocked by this now, we would like to install new and separate server on a 3 GB memory server (1 GB for OS and 2 GB for Sonar Qube) and install the scanner on our existing instance where source code is available.

P.S. Ours is small scale project

Please advice if this is right configuration?

Thanks,
~Ram

Hi Ram,

I understand your confusion!

In fact, there’s no need to install the scanner and the server together. In fact, it’s best practice not to.

From the docs I guess this should be good for a small instance.

 
HTH,
Ann