Run Code Analysis task (V4.6.0) for SonarQube fails with Java heap space error

Hi,

SonarQube - V7.6 Community Edition
TFS 2017 Update 3
SonarQube Code Analysis Extension - 4.6.0

We’re using the Code Analysis Extension for a C# project and this fails with the following error:-

2019-03-06T09:49:51.2487943Z INFO: ------------------------------------------------------------------------
2019-03-06T09:49:51.2487943Z INFO: EXECUTION FAILURE
2019-03-06T09:49:51.2487943Z INFO: ------------------------------------------------------------------------
2019-03-06T09:49:51.2487943Z INFO: Total time: 1:35.637s
2019-03-06T09:49:51.3112946Z INFO: Final Memory: 8M/247M
2019-03-06T09:49:51.3112946Z INFO: ------------------------------------------------------------------------
2019-03-06T09:49:51.3112946Z ##[error]ERROR: Error during SonarQube Scanner execution
2019-03-06T09:49:51.3112946Z ERROR: Error during SonarQube Scanner execution
2019-03-06T09:49:51.3112946Z ##[error]ERROR: Java heap space
ERROR:
2019-03-06T09:49:51.3112946Z ERROR: Java heap space
2019-03-06T09:49:51.3112946Z ERROR:
2019-03-06T09:49:51.3737916Z ##[error]The SonarQube Scanner did not complete successfully

When I revert back to V4.5.1 of the Code Analysis Extension this runs successfully.

Also, is there a way to prevent this extension from automatically updating to the latest version?

Thanks

Hi @dazfez,

Thank you for reporting this issue. We did a change on the scanner in v4.6 which is removing a default setting forcing the JVM size to be 1GB because when the parameter is not forced, the JVM defaults to 1/4 of the available memory which seemed to be a better default most of the time. It seems that on your case this new default is less favorable.

You can set the SONAR_SCANNER_OPTS environment variable to -Xmx1024m (or to any higher value) to allow the JVM to have more memory.

Cheers,
Amaury

Hi Amaury,

Thanks for your quick response.
I did try setting this (on the machine where SonarQube is installed) to -Xmx512m and it didn’t seem to effect anything. It was still reporting 247M in my error. I’m pretty sure that I restarted SonarQube too.
Is there anything else I need to do?

Thanks again,

Darren

Hi Darren,

The error you are seeing happens with the scanner, not with SonarQube.
The environment variable should be set in the machine where the scan is executed.

Hi Duarte,

I’ve added the environment variable to the machine where the scan is executed and this is now working successfully. I did wonder if I was setting it on the wrong machine!

Thanks both for your helping me to resolve this issue.

Darren