# Addressing memory issues using traditional Azure DevOps pipeline and personally hosted build agents

**URL:** <https://community.sonarsource.com/t/addressing-memory-issues-using-traditional-azure-devops-pipeline-and-personally-hosted-build-agents/124345>\
**Category:** SonarQube Cloud\
**Tags:** java\
**Created:** [September 3, 2024, 7:26am UTC](https://community.sonarsource.com/t/addressing-memory-issues-using-traditional-azure-devops-pipeline-and-personally-hosted-build-agents/124345 "2024-09-03T07:26:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![southernsun](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/southernsun/32/61300_2.png) [@southernsun](https://community.sonarsource.com/u/southernsun)\
**Post date:** [September 3, 2024, 7:26am UTC](https://community.sonarsource.com/t/addressing-memory-issues-using-traditional-azure-devops-pipeline-and-personally-hosted-build-agents/124345/1 "2024-09-03T07:26:52Z")

</div>

We use:

- Azure DevOps traditional pipeline definitions
- Azure DevOps TFS for source control
- Custom build agents
- SonarCloud
- C# is our main programming language  
Error:

> ##[error]java.lang.OutOfMemoryError: Java heap space

I’ve read different topics and different suggestions, but they are typically referring to a personally hosted SonarQube setup or .yaml based pipeline and don’t seem to work.

How should I configure the pipeline to address this “Java heap space” problem? What settings to use and where to configure? How can i make sure this will continue to be working when i move to a hosted build agent from Microsoft?

Full error:

```auto
2024-08-30T21:46:44.5050366Z ##[error]ERROR: Error in thread nodejs-stream-consumer
java.lang.OutOfMemoryError: Java heap space
2024-08-30T21:46:44.5051740Z ERROR: Error in thread nodejs-stream-consumer
2024-08-30T21:46:44.5052076Z java.lang.OutOfMemoryError: Java heap space
2024-08-30T21:46:44.5053091Z 
2024-08-30T21:46:47.2089212Z INFO: ------------------------------------------------------------------------
2024-08-30T21:46:47.2095591Z INFO: EXECUTION FAILURE
2024-08-30T21:46:47.2096318Z INFO: ------------------------------------------------------------------------
2024-08-30T21:46:47.2103010Z INFO: Total time: 28:03.005s
2024-08-30T21:46:47.2747651Z INFO: Final Memory: 97M/376M
2024-08-30T21:46:47.2748418Z INFO: ------------------------------------------------------------------------
2024-08-30T21:46:47.2752191Z ##[error]ERROR: Error during SonarScanner execution
2024-08-30T21:46:47.2752980Z ERROR: Error during SonarScanner execution
2024-08-30T21:46:47.2756580Z ##[error]java.lang.OutOfMemoryError: Java heap space
2024-08-30T21:46:47.2757184Z java.lang.OutOfMemoryError: Java heap space
2024-08-30T21:46:47.2757997Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$AssignCall.newBuilderForType(na:4946)
2024-08-30T21:46:47.2758701Z at org.sonar.ucfg.protobuf.UcfgProtos$AssignCall.newBuilderForType(na:4946)
2024-08-30T21:46:47.2759567Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$AssignCall.newBuilderForType(na:5942)
2024-08-30T21:46:47.2760762Z at org.sonar.ucfg.protobuf.UcfgProtos$AssignCall.newBuilderForType(na:5942)
2024-08-30T21:46:47.2761636Z ##[error]at com.google.protobuf.GeneratedMessageV3.newBuilderForType(na:3528)
2024-08-30T21:46:47.2762301Z at com.google.protobuf.GeneratedMessageV3.newBuilderForType(na:3528)
2024-08-30T21:46:47.2763115Z ##[error]at com.google.protobuf.SingleFieldBuilderV3.getBuilder(na:3450)
2024-08-30T21:46:47.2763763Z at com.google.protobuf.SingleFieldBuilderV3.getBuilder(na:3450)
2024-08-30T21:46:47.2764607Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$Instruction$Builder.mergeFrom(na:4044)
2024-08-30T21:46:47.2765304Z at org.sonar.ucfg.protobuf.UcfgProtos$Instruction$Builder.mergeFrom(na:4044)
2024-08-30T21:46:47.2766633Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$Instruction$1.K(na:6005)
	at org.sonar.ucfg.protobuf.UcfgProtos$Instruction$1.parsePartialFrom(na:6250)
	at com.google.protobuf.CodedInputStream$StreamDecoder.readMessage(na:1538)
2024-08-30T21:46:47.2767579Z at org.sonar.ucfg.protobuf.UcfgProtos$Instruction$1.K(na:6005)
2024-08-30T21:46:47.2767957Z at org.sonar.ucfg.protobuf.UcfgProtos$Instruction$1.parsePartialFrom(na:6250)
2024-08-30T21:46:47.2768360Z at com.google.protobuf.CodedInputStream$StreamDecoder.readMessage(na:1538)
2024-08-30T21:46:47.2769222Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$BasicBlock$Builder.mergeFrom(na:2043)
2024-08-30T21:46:47.2769914Z at org.sonar.ucfg.protobuf.UcfgProtos$BasicBlock$Builder.mergeFrom(na:2043)
2024-08-30T21:46:47.2770759Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$BasicBlock$1.I(na:5103)
2024-08-30T21:46:47.2771411Z at org.sonar.ucfg.protobuf.UcfgProtos$BasicBlock$1.I(na:5103)
2024-08-30T21:46:47.2772227Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$BasicBlock$1.parsePartialFrom(na:5896)
2024-08-30T21:46:47.2772929Z at org.sonar.ucfg.protobuf.UcfgProtos$BasicBlock$1.parsePartialFrom(na:5896)
2024-08-30T21:46:47.2773774Z ##[error]at com.google.protobuf.CodedInputStream$StreamDecoder.readMessage(na:1538)
2024-08-30T21:46:47.2774676Z at com.google.protobuf.CodedInputStream$StreamDecoder.readMessage(na:1538)
2024-08-30T21:46:47.2775527Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$UCFG$Builder.mergeFrom(na:1924)
2024-08-30T21:46:47.2776200Z at org.sonar.ucfg.protobuf.UcfgProtos$UCFG$Builder.mergeFrom(na:1924)
2024-08-30T21:46:47.2777001Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$UCFG$1.L(na:1659)
2024-08-30T21:46:47.2777621Z at org.sonar.ucfg.protobuf.UcfgProtos$UCFG$1.L(na:1659)
2024-08-30T21:46:47.2778436Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$UCFG$1.parsePartialFrom(na:45)
2024-08-30T21:46:47.2779145Z at org.sonar.ucfg.protobuf.UcfgProtos$UCFG$1.parsePartialFrom(na:45)
2024-08-30T21:46:47.2779967Z ##[error]at com.google.protobuf.AbstractParser.parsePartialFrom(na:3542)
2024-08-30T21:46:47.2780601Z at com.google.protobuf.AbstractParser.parsePartialFrom(na:3542)
2024-08-30T21:46:47.2781421Z ##[error]at com.google.protobuf.AbstractParser.parsePartialDelimitedFrom(na:3060)
2024-08-30T21:46:47.2782103Z at com.google.protobuf.AbstractParser.parsePartialDelimitedFrom(na:3060)
2024-08-30T21:46:47.2782960Z ##[error]at com.google.protobuf.AbstractParser.parseDelimitedFrom(na:3062)
2024-08-30T21:46:47.2783616Z at com.google.protobuf.AbstractParser.parseDelimitedFrom(na:3062)
2024-08-30T21:46:47.2784430Z ##[error]at com.google.protobuf.AbstractParser.parseDelimitedFrom(na:683)
2024-08-30T21:46:47.2785172Z at com.google.protobuf.AbstractParser.parseDelimitedFrom(na:683)
2024-08-30T21:46:47.2786016Z ##[error]at com.google.protobuf.AbstractParser.parseDelimitedFrom(na:1940)
2024-08-30T21:46:47.2786656Z at com.google.protobuf.AbstractParser.parseDelimitedFrom(na:1940)
2024-08-30T21:46:47.2787558Z ##[error]at com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(na:2884)
2024-08-30T21:46:47.2788267Z at com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(na:2884)
2024-08-30T21:46:47.2789100Z ##[error]at org.sonar.ucfg.protobuf.UcfgProtos$UCFG.parseDelimitedFrom(na:99)
2024-08-30T21:46:47.2789928Z at org.sonar.ucfg.protobuf.UcfgProtos$UCFG.parseDelimitedFrom(na:99)
2024-08-30T21:46:47.2790623Z ##[error]at com.sonar.A.D.C(na:942)
2024-08-30T21:46:47.2791237Z at com.sonar.A.D.C(na:942)
2024-08-30T21:46:47.2791894Z ##[error]at com.sonar.security.A.B.A(na:3399)
2024-08-30T21:46:47.2792436Z at com.sonar.security.A.B.A(na:3399)
2024-08-30T21:46:47.2793095Z ##[error]at com.sonar.security.E.A(na:3362)
2024-08-30T21:46:47.2793628Z at com.sonar.security.E.A(na:3362)
2024-08-30T21:46:47.2794352Z ##[error]at com.sonar.security.E.readUcfgs(na:1061)
2024-08-30T21:46:47.2795067Z at com.sonar.security.E.readUcfgs(na:1061)
2024-08-30T21:46:47.2796177Z ##[error]at com.sonar.security.E.A(na:3242)
2024-08-30T21:46:47.2796750Z at com.sonar.security.E.A(na:3242)
2024-08-30T21:46:47.2797262Z ##[error]at com.sonar.security.E.A(na:342)
2024-08-30T21:46:47.2797702Z at com.sonar.security.E.A(na:342)
2024-08-30T21:46:47.2798258Z ##[error]at com.sonar.security.E.executeChecks(na:3263)
2024-08-30T21:46:47.2798719Z at com.sonar.security.E.executeChecks(na:3263)
2024-08-30T21:46:47.2799272Z ##[error]at com.sonar.security.E.executeChecks(na:2918)
2024-08-30T21:46:47.2799718Z at com.sonar.security.E.executeChecks(na:2918)
2024-08-30T21:46:47.2800254Z ##[error]at com.sonar.security.E.execute(na:860)
2024-08-30T21:46:47.2800777Z at com.sonar.security.E.execute(na:860)
2024-08-30T21:46:47.2801333Z ##[error]at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:63)
2024-08-30T21:46:47.2801833Z at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:63)
2024-08-30T21:46:47.2802274Z ##[error]ERROR:
2024-08-30T21:46:47.2802574Z ERROR: 
2024-08-30T21:46:47.3815333Z ##[error]The SonarScanner did not complete successfully

```

Thanks!

---

<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 4, 2024, 7:32am UTC](https://community.sonarsource.com/t/addressing-memory-issues-using-traditional-azure-devops-pipeline-and-personally-hosted-build-agents/124345/2 "2024-09-04T07:32:44Z")

</div>

Hey there.

You can adjust the [`SONAR_SCANNER_JAVA_OPTS`](https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/analysis-parameters/#other-parameters) variable in your pipeline (see [Set variables in Pipelines \> Classic](https://learn.microsoft.com/en-us/azure/devops/pipelines/process/variables?view=azure-devops&tabs=classic%2Cbatch#set-variables-in-pipeline).

For what it’s worth, you can also simply use an analysis parameter rather than an environment variable (`sonar.scanner.javaOpts`)

A good starting value would be `-Xmx2G`.

---

<div class="post-metadata">

**Author:** ![southernsun](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/southernsun/32/61300_2.png) [@southernsun](https://community.sonarsource.com/u/southernsun)\
**Post date:** [September 4, 2024, 8:00am UTC](https://community.sonarsource.com/t/addressing-memory-issues-using-traditional-azure-devops-pipeline-and-personally-hosted-build-agents/124345/3 "2024-09-04T08:00:34Z")

</div>

Thank you! i will try this and let you know how it goes!

---

<div class="post-metadata">

**Author:** ![southernsun](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/southernsun/32/61300_2.png) [@southernsun](https://community.sonarsource.com/u/southernsun)\
**Post date:** [September 4, 2024, 9:39pm UTC](https://community.sonarsource.com/t/addressing-memory-issues-using-traditional-azure-devops-pipeline-and-personally-hosted-build-agents/124345/4 "2024-09-04T21:39:31Z")

</div>

it still failed with the same error message:

> ##[error]Exception in thread “HttpClient-1-SelectorManager” java.lang.OutOfMemoryError: Java heap space
> 
> Exception in thread “HttpClient-1-SelectorManager” java.lang.OutOfMemoryError: Java heap space
> 
> INFO: ------------------------------------------------------------------------
> 
> INFO: EXECUTION FAILURE
> 
> INFO: ------------------------------------------------------------------------
> 
> INFO: Total time: 29:13.153s
> 
> INFO: Final Memory: 98M/376M
> 
> INFO: ------------------------------------------------------------------------
> 
> ##[error]ERROR: Error during SonarScanner execution

Is there anyway i can easily check if the settings made any difference? should i perhaps do a print out before the analyse task to print out the variables? or specify some other settings? Or some verbose logging?

---

<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 6, 2024, 10:25am UTC](https://community.sonarsource.com/t/addressing-memory-issues-using-traditional-azure-devops-pipeline-and-personally-hosted-build-agents/124345/6 "2024-09-06T10:25:36Z")

</div>

If you turn on `DEBUG` level logging (`sonar.verbose=true`), you should see a message like this at the beginning of your scanner logs.

`12:24:30.017 DEBUG Scanner max available memory: 2 GB`

If you see this, and still face the issue… my next suggestion is to bump the memory up again, from `-Xmx2G` to `-Xmx4G`.

---

<div class="post-metadata">

**Author:** ![southernsun](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/southernsun/32/61300_2.png) [@southernsun](https://community.sonarsource.com/u/southernsun)\
**Post date:** [September 12, 2024, 8:27am UTC](https://community.sonarsource.com/t/addressing-memory-issues-using-traditional-azure-devops-pipeline-and-personally-hosted-build-agents/124345/7 "2024-09-12T08:27:51Z")

</div>

Thanks, we set it to -Xmx16G, which seemed to have resolve our issues at the moment. Thank you!

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/system/32/31083_2.png) [@system](https://community.sonarsource.com/u/system)\
**Post date:** [September 19, 2024, 8:28am UTC](https://community.sonarsource.com/t/addressing-memory-issues-using-traditional-azure-devops-pipeline-and-personally-hosted-build-agents/124345/8 "2024-09-19T08:28:50Z")

</div>

Closed on September 19, 2024, 8:28am UTC

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
