# Java.lang.OutofMemoryError : Java heap space, during SonarQube execution for C++

**URL:** <https://community.sonarsource.com/t/java-lang-outofmemoryerror-java-heap-space-during-sonarqube-execution-for-c/34883>\
**Category:** SonarQube Server / Community Build\
**Tags:** cfamily, scanner\
**Created:** [November 23, 2020, 10:28pm UTC](https://community.sonarsource.com/t/java-lang-outofmemoryerror-java-heap-space-during-sonarqube-execution-for-c/34883 "2020-11-23T22:28:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![David\_Carson](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_carson/32/17156_2.png) [@David\_Carson](https://community.sonarsource.com/u/David_Carson)\
**Post date:** [November 23, 2020, 10:28pm UTC](https://community.sonarsource.com/t/java-lang-outofmemoryerror-java-heap-space-during-sonarqube-execution-for-c/34883/1 "2020-11-23T22:28:37Z")

</div>

Increasing heap space via SONAR\_SCANNER\_OPTS does not seem to help for me.

Here is my environment:

> 17:11:30.835 INFO: Scanner configuration file: /opt/dcc/dcarson/sonar-scanner-4.5.0.2216-linux/conf/sonar-scanner.properties  
> 17:11:30.837 INFO: Project root configuration file: NONE  
> 17:11:30.851 INFO: SonarScanner 4.5.0.2216  
> 17:11:30.851 INFO: Java 11.0.3 AdoptOpenJDK (64-bit)  
> 17:11:30.851 INFO: Linux 3.10.0-1127.19.1.el7.x86\_64 amd64  
> 17:11:30.851 INFO: SONAR\_SCANNER\_OPTS=-Xmx4196m

- running sonar-scanner from a Linux command line (bash)
- executing ‘export SONAR\_SCANNER\_OPTS=-Xmx512m’ from command line to insert into environment, then running sonar-scanner (not setting this value in a config file)
- I’ve tried as high as 4196m (i.e., 4GB) and still get the OutOfMemoryError: Java heap space

This is a trial key test to see if the product could replace our current static analysis tool. I am analyzing all C/C++ files in my checked-out clone. According to the log, my file filter is finding about 33K files based on my inclusion pattern.

Every attempt with a larger heap gives the same error.

---

<div class="post-metadata">

**Author:** ![mpaladin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mpaladin/32/118_2.png) [@mpaladin](https://community.sonarsource.com/u/mpaladin)\
**Post date:** [November 24, 2020, 8:05am UTC](https://community.sonarsource.com/t/java-lang-outofmemoryerror-java-heap-space-during-sonarqube-execution-for-c/34883/2 "2020-11-24T08:05:38Z")

</div>

Hi @David_Carson,

would you be able to share the entire output log? If you cannot do it here I can send you a PM where you can share privately.

---

<div class="post-metadata">

**Author:** ![David\_Carson](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/david_carson/32/17156_2.png) [@David\_Carson](https://community.sonarsource.com/u/David_Carson)\
**Post date:** [November 24, 2020, 1:49pm UTC](https://community.sonarsource.com/t/java-lang-outofmemoryerror-java-heap-space-during-sonarqube-execution-for-c/34883/3 "2020-11-24T13:49:38Z")

</div>

Do you want a log including debug (with -X set)? That is quite large. If not, I’ll see if I can post the non-debug log. It may contain proprietary info in which case I’ll probably want to post it privately.

---

<div class="post-metadata">

**Author:** ![mpaladin](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/mpaladin/32/118_2.png) [@mpaladin](https://community.sonarsource.com/u/mpaladin)\
**Post date:** [November 24, 2020, 2:37pm UTC](https://community.sonarsource.com/t/java-lang-outofmemoryerror-java-heap-space-during-sonarqube-execution-for-c/34883/4 "2020-11-24T14:37:24Z")

</div>

Hi @David_Carson,

I sent you a PM.

---

<div class="post-metadata">

**Author:** ![sagargahalod](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/sagargahalod/32/62772_2.png) [@sagargahalod](https://community.sonarsource.com/u/sagargahalod)\
**Post date:** [April 22, 2022, 1:04pm UTC](https://community.sonarsource.com/t/java-lang-outofmemoryerror-java-heap-space-during-sonarqube-execution-for-c/34883/6 "2022-04-22T13:04:49Z")

</div>

@mpaladin @David_Carson How did you resolve this issue? I am also getting the same memory issue.

---

<div class="post-metadata">

**Author:** ![Tomasz\_Kaminski](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/tomasz_kaminski/32/20007_2.png) [@Tomasz\_Kaminski](https://community.sonarsource.com/u/Tomasz_Kaminski)\
**Post date:** [April 25, 2022, 7:42am UTC](https://community.sonarsource.com/t/java-lang-outofmemoryerror-java-heap-space-during-sonarqube-execution-for-c/34883/7 "2022-04-25T07:42:32Z")

</div>

Welcome to the community @sagargahalod!

As this thread is from more years ago, a lot has changed from that time (for example a new LTS was released), given that it is possible that even if the symptoms are the same, the root cause of the issue is different. Could you please start a new thread for your issues and post the output log there?
