Exception in thread "main" java.lang.OutOfMemoryError: Java heap space

Template for a good new topic, formatted with Markdown:

  • ALM used (GitHub, Bitbucket Cloud, Azure DevOps): Azure DevOps
  • CI system used (Bitbucket Cloud, Azure DevOps, Travis CI, Circle CI: Azure DevOps
  • Scanner command used when applicable (private details masked): Sonar analysis
  • Languages of the repository: Angular (JS and TS)
  • Only if the SonarCloud project is public, the URL
    • And if you need help with pull request decoration, then the URL to the PR too
  • Error observed (wrap logs/code around with triple quotes ``` for proper formatting)
  • Steps to reproduce:
  •  # Perform Sonar Cloud Analysis
    - task: SonarCloudAnalyze@2
      displayName: Perform Sonar Cloud Analysis
      inputs:
        jdkversion: "JAVA_HOME_17_X64"
      env:
        SONAR_SCANNER_OPTS: "-Xmx16g"
    
  • Potential workaround

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)
16:15:07.559 ERROR isAlive was interrupted
java.lang.InterruptedException: null
	at java.base/java.util.concurrent.CompletableFuture.reportGet(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture.get(Unknown Source)
	at java.net.http/jdk.internal.net.http.HttpClientImpl.send(Unknown Source)
	at java.net.http/jdk.internal.net.http.HttpClientFacade.send(Unknown Source)
	at org.sonar.plugins.javascript.bridge.BridgeServerImpl.isAlive(BridgeServerImpl.java:431)
	at org.sonar.plugins.javascript.bridge.BridgeServerImpl.heartbeat(BridgeServerImpl.java:139)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.runAndReset(Unknown Source)
	at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

##[error]16:15:45.112 ERROR [stderr] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
16:15:45.112 ERROR [stderr] Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
##[error]16:15:45.112 ERROR [stderr] 	at com.sonar.security.F.D.D.Y.A(na:845)
16:15:45.112 ERROR [stderr] 	at com.sonar.security.F.D.D.Y.A(na:2161)
16:15:45.112 ERROR [stderr] 	at com.sonar.security.F.D.B.O.A(na:2223)

Hey there

Try swapping this for SONAR_SCANNER_JAVA_OPTS (docs)