Java Heap space error

Implemented SonarQube with VSTS Build and during Run Code Analysis Task getting below mentioned error, please suggest!

ERROR: Error during SonarQube Scanner execution

ERROR: Java heap space

ERROR:

The SonarQube Scanner did not complete successfully

14:17:48.219 Post-processing failed. Exit code: 1

H:\Agent9_tasks\SonarQubePrepare_15b84ca1-b62f-4a2a-a403-89b77a063157\4.6.0\classic-sonar-scanner-msbuild\SonarScanner.MSBuild.exe failed with return code: 1

Kanika,

Did you take a look at the SonarQube Scanner CLI documentation where the Java heap space error is specifically called out?

Best regards,

Colin

Thanks for the quick response Colin.

In task, I have defined the Additional Properties as:

Additional properties that will be passed to the scanner,

Put one key=value per line, example:

sonar.exclusions=**/*.bin

SONAR_SCANNER_OPTS=-Xmx3072m

After this also, I am getting the error!

Kanika,

The documentation mentions using SONAR_SCANNER_OPTS as an environment variable, not an analysis parameter, and explicitly suggests how to set it (in TFS, you can probably just add it in the Variables section of your build)

Best regards,

Colin

Hi Colin,

After updting this in Environment variables, error has changed:

Using the supplied value for SONAR_SCANNER_OPTS. Value: -Xmx2048M

Calling the SonarQube Scanner…

Error occurred during initialization of VM

Could not reserve enough space for 2097152KB object heap

##[error]The SonarQube Scanner did not complete successfully

The SonarQube Scanner did not complete successfully

##[error]18:32:00.498 Post-processing failed. Exit code: 1

18:32:00.498 Post-processing failed. Exit code: 1