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)
  • 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: ------------------------------------------------------------------------
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(
        at org.sonar.scanner.protocol.output.ScannerReport$SyntaxHighlightingRule$
        at org.sonar.scanner.sensor.DefaultSensorStorage.lambda$store$1(
        at org.sonar.scanner.sensor.DefaultSensorStorage$$Lambda$1186/0x0000000100970c40.apply(Unknown Source)

Best regards,


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

Regarding heap space, the docs should help.


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.

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?


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.