# Unable to create Java Virtual Machine Error while running analysis

**URL:** <https://community.sonarsource.com/t/unable-to-create-java-virtual-machine-error-while-running-analysis/2586>\
**Category:** SonarQube Server / Community Build\
**Created:** [September 14, 2018, 1:24pm UTC](https://community.sonarsource.com/t/unable-to-create-java-virtual-machine-error-while-running-analysis/2586 "2018-09-14T13:24:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikitha.appana](https://avatars.discourse-cdn.com/v4/letter/n/d2c977/32.png) [@nikitha.appana](https://community.sonarsource.com/u/nikitha.appana)\
**Post date:** [September 14, 2018, 1:24pm UTC](https://community.sonarsource.com/t/unable-to-create-java-virtual-machine-error-while-running-analysis/2586/1 "2018-09-14T13:24:05Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Colin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/colin/32/55255_2.png) [@Colin](https://community.sonarsource.com/u/Colin)\
**Post date:** [September 14, 2018, 1:42pm UTC](https://community.sonarsource.com/t/unable-to-create-java-virtual-machine-error-while-running-analysis/2586/2 "2018-09-14T13:42:48Z")

</div>

Nikita,

[Please do not post duplicate threads](https://community.sonarsource.com/t/postprocessing-step-failing-to-publish-scanner-results/2446)

That said, your issue smells a little like [this issue posted on StackOverflow](https://stackoverflow.com/questions/31172510/java-invalid-maximum-heap-size-the-specified-size-exceeds-the-maximum-represent/34627862). 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](https://docs.sonarqube.org/pages/viewpage.action?pageId=6954796#AnalyzingwithSonarQubeScanner-Troubleshooting).

(Note: the latest version of the [SonarQube Scanner for MSBuild](https://docs.sonarqube.org/pages/viewpage.action?pageId=6954799) is 4.3.1)

Colin

---

<div class="post-metadata">

**Author:** ![agabrys](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/agabrys/32/2744_2.png) [@agabrys](https://community.sonarsource.com/u/agabrys)\
**Post date:** [September 16, 2018, 8:07am UTC](https://community.sonarsource.com/t/unable-to-create-java-virtual-machine-error-while-running-analysis/2586/3 "2018-09-16T08:07:52Z")

</div>

This question is everywhere 😉

> <https://stackoverflow.com/questions/52333122/unable-to-create-java-virtual-machine-error-while-running-sonar-analysis>

---

<div class="post-metadata">

**Author:** ![galewinston](https://avatars.discourse-cdn.com/v4/letter/g/c89c15/32.png) [@galewinston](https://community.sonarsource.com/u/galewinston)\
**Post date:** [June 14, 2021, 7:05am UTC](https://community.sonarsource.com/t/unable-to-create-java-virtual-machine-error-while-running-analysis/2586/4 "2021-06-14T07:05:15Z")

</div>

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](http://net-informations.com/java/intro/jvm.htm) 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
