Unable to create Java Virtual Machine Error while running analysis

Version Used :: SonarQube 7.3 integrated with TC using SonarScanner using version sonar-scanner-msbuild.4.0.2.892

Error received

Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.*
Invalid maximum heap size: -Xmx14336m*
The specified size exceeds the maximum representable size.*
Process returned exit code 1*
The SonarQube Scanner did not complete successfully*
Creating a summary markdown file…*
Post-processing failed. Exit code: 1*
Process exited with code 1*

Steps Taken

I tried various values of Xmx and elastic search Xmx values to get over the error, but the MSbuild step which is inbetween the begin and end analysis steps runs for almost 6 hrs and fails at the end analysis step. Just to add into perspective I am scanning over 10M Loc

History of the problem
The solution scan did work in the past with sonar runner version and when I took over the project 6 months ago I upgraded Sonar to 6.7 LTS and integrated it with TC, the project had failed to run with the same error in the past and I left it intermittently, I recently restarted it with another upgrade to Sonar 7.3. I am really stuck on getting this issue resolved and be able to re-run the scans.

Nikita,

Please do not post duplicate threads

That said, your issue smells a little like this issue posted on StackOverflow. You could try lowering your heap size but better yet, make sure you’re running a 64 bit JVM. I would suspect something changed on your build machines with regard to the Java installation.

A reminder that anything set in sonar.propeties (as you mentioned in your other thread) is only relevant on the server-side, not the scanning side. Setting JVM options for the Scanner is done as documented here.

(Note: the latest version of the SonarQube Scanner for MSBuild is 4.3.1)

Colin

2 Likes

This question is everywhere :wink:

There is not enough virtual memory space requested by an application thus the application fails to start. This usually happens during the application startup phase. Applications reserve a large amount of virtual memory for the JVM heap space during the startup phase. Java on Windows uses an initial size of 16 Megabyte and a maximum of 64 Megabyte.

Most of the time you can fix this problem by uninstalling the Java runtime and then reinstalling it all over again. You can also try increasing the amount of system memory allocated to the Java virtual machine by setting an environment variable.

Open the Control Panel
Go to System
Go to Advanced Systems Properties
Then Environment Variables
In System Variables, click Add
New Variable Name: _JAVA_OPTIONS
New Variable Value: -Xmx512M
Click OK