# Java Heap space error

**URL:** <https://community.sonarsource.com/t/java-heap-space-error/8847>\
**Category:** SonarQube Server / Community Build\
**Created:** [April 16, 2019, 8:54am UTC](https://community.sonarsource.com/t/java-heap-space-error/8847 "2019-04-16T08:54:38Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![KanikaKumar-GEP](https://avatars.discourse-cdn.com/v4/letter/k/ba8739/32.png) [@KanikaKumar-GEP](https://community.sonarsource.com/u/KanikaKumar-GEP)\
**Post date:** [April 16, 2019, 8:54am UTC](https://community.sonarsource.com/t/java-heap-space-error/8847/1 "2019-04-16T08:54:38Z")

</div>

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

---

<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:** [April 16, 2019, 9:01am UTC](https://community.sonarsource.com/t/java-heap-space-error/8847/2 "2019-04-16T09:01:33Z")

</div>

Kanika,

Did you take a look at the [SonarQube Scanner CLI](https://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner#AnalyzingwithSonarQubeScanner-Troubleshooting) documentation where the Java heap space error is specifically called out?

Best regards,

Colin

---

<div class="post-metadata">

**Author:** ![KanikaKumar-GEP](https://avatars.discourse-cdn.com/v4/letter/k/ba8739/32.png) [@KanikaKumar-GEP](https://community.sonarsource.com/u/KanikaKumar-GEP)\
**Post date:** [April 16, 2019, 9:03am UTC](https://community.sonarsource.com/t/java-heap-space-error/8847/3 "2019-04-16T09:03:52Z")

</div>

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!

---

<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:** [April 16, 2019, 9:06am UTC](https://community.sonarsource.com/t/java-heap-space-error/8847/4 "2019-04-16T09:06:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![KanikaKumar-GEP](https://avatars.discourse-cdn.com/v4/letter/k/ba8739/32.png) [@KanikaKumar-GEP](https://community.sonarsource.com/u/KanikaKumar-GEP)\
**Post date:** [April 16, 2019, 1:23pm UTC](https://community.sonarsource.com/t/java-heap-space-error/8847/5 "2019-04-16T13:23:00Z")

</div>

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
