java.lang.OutOfMemoryError: Java heap space in jenkins sonar scan stage

Hi guys,

I run into the same trouble.

I have Jenkinsfile code pice.

stage('sonarqube') { 
  withSonarQubeEnv() {    
    sh "bazel run //:sq -- -Dsonar.host.url=${env.SONAR_HOST_URL} -Dsonar.login=${env.SONAR_AUTH_TOKEN} -Dsonar.projectVersion=${kcpVersion}"
  }
  waitForQualityGate( abortPipeline: true )
}

And after analysis successfully completed it hanging about 2.5minutes and pipeline fails

java.lang.OutOfMemoryError: Java heap space
Also:   org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 6c3dceb8-cd03-4eb4-a5c5-583554eeae0f
Caused: java.io.IOException: Remote call on JNLP4-connect connection from 100.96.12.165/100.96.12.165:49872 failed
	at hudson.remoting.Channel.call(Channel.java:1004)
	at hudson.FilePath.act(FilePath.java:1192)
	at hudson.FilePath.act(FilePath.java:1181)
	at hudson.FilePath.list(FilePath.java:2131)
	at hudson.FilePath.list(FilePath.java:2114)
	at hudson.FilePath.list(FilePath.java:2098)
	at hudson.plugins.sonar.utils.SonarUtils.extractReportTask(SonarUtils.java:96)
	at hudson.plugins.sonar.utils.SonarUtils.addBuildInfoTo(SonarUtils.java:136)
	at hudson.plugins.sonar.SonarBuildWrapper$AddBuildInfo.tearDown(SonarBuildWrapper.java:230)
	at org.jenkinsci.plugins.workflow.steps.CoreWrapperStep$Callback.finished(CoreWrapperStep.java:207)
	at org.jenkinsci.plugins.workflow.steps.CoreWrapperStep$Execution2$Callback2.finished(CoreWrapperStep.java:150)
	at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution$TailCall.lambda$onSuccess$0(GeneralNonBlockingStepExecution.java:140)
	at org.jenkinsci.plugins.workflow.steps.GeneralNonBlockingStepExecution.lambda$run$0(GeneralNonBlockingStepExecution.java:77)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
	at java.base/java.util.concurrent.FutureTask.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)
Finished: FAILURE

I suppose the problem is not in sonar-scanner, but at withSonarQubeEnv() sonar Jenkins plugin.

Have you found how to solve this?