java.lang.OutOfMemoryError: Java heap space using Microsoft hosted agents after

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps, using ubuntu-latest, Microsoft hosted agents
  • Scanner command used when applicable: SonarCloudAnalyze@1
  • Languages of the repository: C#, Typescript
  • Error observed
2023-10-10T09:51:05.1245637Z 09:51:05.123 DEBUG: the bridge server closed
2023-10-10T09:51:05.1245991Z 09:51:05.123 INFO: Time spent writing ucfgs 80ms
2023-10-10T09:51:05.6583735Z 09:51:05.657 INFO: ------------------------------------------------------------------------
2023-10-10T09:51:05.6592770Z 09:51:05.659 INFO: EXECUTION FAILURE
2023-10-10T09:51:05.6600854Z 09:51:05.659 INFO: ------------------------------------------------------------------------
2023-10-10T09:51:05.6610981Z 09:51:05.660 INFO: Total time: 9:12.152s
2023-10-10T09:51:05.7434418Z 09:51:05.742 INFO: Final Memory: 27M/100M
2023-10-10T09:51:05.7435742Z 09:51:05.742 INFO: ------------------------------------------------------------------------
2023-10-10T09:51:05.7444467Z ##[error]09:51:05.742 ERROR: Error during SonarScanner execution
java.lang.OutOfMemoryError: Java heap space
	at java.base/
	at java.base/<init>(
	at java.base/
	at org.sonar.plugins.javascript.bridge.TsConfigProvider$LookupTsConfigProvider.tsconfigs(
	at org.sonar.plugins.javascript.bridge.TsConfigProvider.tsconfigs(
	at org.sonar.plugins.javascript.bridge.TsConfigProvider.getTsConfigs(
	at org.sonar.plugins.javascript.bridge.JsTsSensor.analyzeFiles(
	at org.sonar.plugins.javascript.bridge.AbstractBridgeSensor.execute(
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(
	at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$1252/ Source)
2023-10-10T09:51:05.7447144Z 09:51:05.742 ERROR: Error during SonarScanner execution
2023-10-10T09:51:05.7447340Z java.lang.OutOfMemoryError: Java heap space
2023-10-10T09:51:05.7447562Z 	at java.base/
2023-10-10T09:51:05.7447786Z 	at java.base/<init>(
2023-10-10T09:51:05.7448146Z 	at java.base/
2023-10-10T09:51:05.7448438Z 	at org.sonar.plugins.javascript.bridge.TsConfigProvider$LookupTsConfigProvider.tsconfigs(
2023-10-10T09:51:05.7448763Z 	at org.sonar.plugins.javascript.bridge.TsConfigProvider.tsconfigs(
2023-10-10T09:51:05.7449077Z 	at org.sonar.plugins.javascript.bridge.TsConfigProvider.getTsConfigs(
2023-10-10T09:51:05.7449381Z 	at org.sonar.plugins.javascript.bridge.JsTsSensor.analyzeFiles(
2023-10-10T09:51:05.7449673Z 	at org.sonar.plugins.javascript.bridge.AbstractBridgeSensor.execute(
2023-10-10T09:51:05.7449989Z 	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(
2023-10-10T09:51:05.7450291Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
2023-10-10T09:51:05.7450592Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(
2023-10-10T09:51:05.7450902Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor$$Lambda$1252/ Source)
2023-10-10T09:51:05.7454942Z ##[error]at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.scanner.scan.ProjectScanContainer.scan(
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.batch.bootstrapper.Batch.doExecute(
	at org.sonar.batch.bootstrapper.Batch.execute(
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-10-10T09:51:05.7457244Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(
2023-10-10T09:51:05.7457566Z 	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
2023-10-10T09:51:05.7457855Z 	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(
2023-10-10T09:51:05.7458158Z 	at org.sonar.core.platform.ComponentContainer.startComponents(
2023-10-10T09:51:05.7458454Z 	at org.sonar.core.platform.ComponentContainer.execute(
2023-10-10T09:51:05.7458734Z 	at org.sonar.scanner.scan.ProjectScanContainer.scan(
2023-10-10T09:51:05.7459037Z 	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(
2023-10-10T09:51:05.7459431Z 	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(
2023-10-10T09:51:05.7460140Z 	at org.sonar.core.platform.ComponentContainer.startComponents(
2023-10-10T09:51:05.7460522Z 	at org.sonar.core.platform.ComponentContainer.execute(
2023-10-10T09:51:05.7460819Z 	at org.sonar.scanner.bootstrap.ScannerContainer.doAfterStart(
2023-10-10T09:51:05.7461108Z 	at org.sonar.core.platform.ComponentContainer.startComponents(
2023-10-10T09:51:05.7461402Z 	at org.sonar.core.platform.ComponentContainer.execute(
2023-10-10T09:51:05.7461695Z 	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(
2023-10-10T09:51:05.7461983Z 	at org.sonar.core.platform.ComponentContainer.startComponents(
2023-10-10T09:51:05.7462281Z 	at org.sonar.core.platform.ComponentContainer.execute(
2023-10-10T09:51:05.7462546Z 	at org.sonar.batch.bootstrapper.Batch.doExecute(
2023-10-10T09:51:05.7462780Z 	at org.sonar.batch.bootstrapper.Batch.execute(
2023-10-10T09:51:05.7463081Z 	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(
2023-10-10T09:51:05.7463361Z 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-10-10T09:51:06.0898375Z Process returned exit code 1
  • Steps to reproduce: Starting the pipeline

We had 9 projects in our solution, and it worked perfectly.
We’ve added a 10th project (AzureFunctions, C#), with about 670 lines of code, and since then we’ve been getting this error.
I’ve tried only analysing the new project, and it worked, also removing the new project, and it still works. So I’m really confused as to why it stops working with just 1 added project.

1 Like

Hello @EdwinBuynamics,

Welcome to the Sonar community, and many thanks for your feedback!

Since adding and removing this 10th project impacts the analysis outcome for some obscure reason, we might be hitting the default memory limit of the JVM here. Could you try to allocate more memory for the JVM? Here is a guide that will help you to do so.

Please let me know if this changes anything.

Thank you,

Hi @Yassin,

I’ve since not stopped trying to solve my problem, and yesterday ran the scanner with a memory limit of 4096m.

I’m sure that part worked because the logging stated the following:


The code is only about 4k lines in total…


Thanks for already trying that out.

Would it be possible to get the full logs of the analysis, ideally the verbose ones? If those contain sensitive data, just obfuscate whatever information should not be shared.

Thank you,

Hi Yassin,

Here is the link to the logging:

log-20231012-pr-pipeline-obfuscated.txt (873.4 KB)

Thank you,

Hi Yassin,

Thank you Edwin for sharing this issue.

I already have the same issue as Edwin:

  • ALM used: Azure DevOps
  • CI system used: Azure DevOps, using Windows, Microsoft hosted agents
  • Scanner command used when applicable: SonarCloudAnalyze@1
  • Languages of the repository: C#
  • Error observed :
2023-10-12T13:53:02.8234462Z ##[error]ERROR: Error during SonarScanner execution
2023-10-12T13:53:02.8235619Z ERROR: Error during SonarScanner execution
2023-10-12T13:53:02.8240918Z ##[error]java.lang.OutOfMemoryError: Java heap space
2023-10-12T13:53:02.8241611Z java.lang.OutOfMemoryError: Java heap space
2023-10-12T13:53:02.8242267Z ##[error]at java.base/java.util.LinkedHashMap$LinkedKeySet.iterator(
2023-10-12T13:53:02.8243308Z 	at java.base/java.util.LinkedHashMap$LinkedKeySet.iterator(
2023-10-12T13:53:02.8244061Z ##[error]at java.base/java.util.Spliterators$IteratorSpliterator.estimateSize(
2023-10-12T13:53:02.8248544Z 	at java.base/java.util.Spliterators$IteratorSpliterator.estimateSize(
2023-10-12T13:53:02.8249274Z ##[error]at java.base/java.util.Spliterator.getExactSizeIfKnown(
2023-10-12T13:53:02.8250218Z 	at java.base/java.util.Spliterator.getExactSizeIfKnown(
2023-10-12T13:53:02.8251036Z ##[error]at java.base/
2023-10-12T13:53:02.8251820Z 	at java.base/
2023-10-12T13:53:02.8252537Z ##[error]at java.base/
2023-10-12T13:53:02.8253303Z 	at java.base/
2023-10-12T13:53:02.8253904Z ##[error]at java.base/$ReduceOp.evaluateSequential(
2023-10-12T13:53:02.8254422Z 	at java.base/$ReduceOp.evaluateSequential(
2023-10-12T13:53:02.8255117Z ##[error]at java.base/
2023-10-12T13:53:02.8255622Z 	at java.base/
2023-10-12T13:53:02.8256172Z ##[error]at java.base/
2023-10-12T13:53:02.8256655Z 	at java.base/
2023-10-12T13:53:02.8257506Z ##[error]at java.base/
2023-10-12T13:53:02.8258026Z 	at java.base/
2023-10-12T13:53:02.8258523Z ##[error]at
2023-10-12T13:53:02.8258945Z 	at
2023-10-12T13:53:02.8259518Z ##[error]at<init>(na:2315)
2023-10-12T13:53:02.8260073Z 	at<init>(na:2315)
2023-10-12T13:53:02.8260568Z ##[error]at<init>(na:1957)
2023-10-12T13:53:02.8261119Z 	at<init>(na:1957)
2023-10-12T13:53:02.8261602Z ##[error]at<init>(na:1042)
2023-10-12T13:53:02.8262169Z 	at<init>(na:1042)
2023-10-12T13:53:02.8262645Z ##[error]at
2023-10-12T13:53:02.8263173Z 	at
2023-10-12T13:53:02.8263860Z ##[error]at

PS: This error occured Yesterday.

Thank you,

Hello @Amine_Ouadrani,

Thank you for your feedback, and welcome to our Sonar community!

Although the failure also highlights a memory issue with the JVM, the logs show it’s coming from a different analyzer, namely the Security analyzer. Therefore, at first glance, I think it’s unrelated to Edwin’s issue that originates from the JavaScript analyzer.

Please create a different thread with your report with the tags sonarcloud, csharp, and security so that the proper experts can take over and investigate your problem :slight_smile:

Thank you,

1 Like

Hey @EdwinBuynamics,

Thank you for sharing the full logs!

We might be facing a bug triggering an infinite loop while walking the file system when looking for TSConfig files. Please try to set the property sonar.typescript.tsconfigPaths. You can provide a comma-separated list of TSConfig paths relative to your base directory.

Let’s try this workaround and see whether the problem persists or not.


Hi @Yassin,

It seems adding sonar.typescript.tsconfigPaths worked to prevent the loop, but now the analyses seems to analyze from a completely different path. (maybe this was the case before adding sonar.typescript.tsconfigPaths of course)

First I was getting ~2000 issues, because it was analyzing everything, including nuget packages. After adding sonar.sources=src/ and sonar.tests=tests/ that was resolved, but the paths still aren’t matching up.
Issues in SonarCloud (and in comments in Azure DevOps) now have a path starting with home/vsts/work/1/s/src/ instead of just src/.
SonarCloud also gives me a warning: SCM provider autodetection failed. Please use "sonar.scm.provider" to define SCM of your project, or disable the SCM Sensor in the project settings. This warning doesn’t seem strange if it can’t match up the paths correctly with git.

Do you know why the paths aren’t matching up anymore? How can I fix this?

Thank you,

Hello @EdwinBuynamics,

The property I suggested you set for TSConfigs should not impact in any way the path issue you are now facing. I am not sure why the paths aren’t matching up anymore, unfortunately. However, I will ping SonarCloud experts so that they can assist you in that matter.

Regarding the warnings about SCM, those are just pointing out that the scanner is not able to collect data from your configured source code management like git, if any. If they are bothering you and you don’t care about them, you can just disable them with sonar.scm.disabled=true.


Hi Edwin,

We try to keep it to one topic per thread. Otherwise it can get messy, fast. Would you mind creating a new thread with all your details for this question of paths?


Hi @ganncamp,

From my perspective the solution provided by Yassin Kammoun is only a solution to a sympton that started when the paths got messed up.
Because it seems weird that I have to set the tsconfigPaths when the new project doesn’t contain any typescript. (it’s a C# Azure Function).

I think we’re still on the same topic…


Looks like I’ve found the solution: the issue was with the added Azure Function project.

Because of the added Azure Function project the paths got messed up due to a bug in the SonarScanner, and that probably caused a second bug to trigger an infinite loop. Setting the sonar.typescript.tsconfigPaths solved the second bug, but not the first bug.

The solution was adding sonar.projectBaseDir=$(Agent.BuildDirectory)/s/ to the extraProperties of the pipeline task. This is a work around for the first bug, so the second bug doesn’t get triggered.

1 Like

Hello @EdwinBuynamics,

I’m glad you worked through this. Sorry for the inconvenience caused by that bug, hopefully, we’ll get a fix released soon.

Best regards,

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