Java heap space error in sonar scanner with postgres sql on LINUX

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
  • what are you trying to achieve
  • what have you tried so far to achieve this

Hi Team,

we are running sonar scanner on our c,c++ project, while scanning on few modules the analysis get successful, however the scan report that gets generated is not uploaded.
The background tasks shows failed with teh “java heap space” error

Error Details
java.lang.OutOfMemoryError: Java heap space
at org.postgresql.util.PGbytea.toBytesHexEscaped(
at org.postgresql.util.PGbytea.toBytes(
at org.postgresql.jdbc.PgResultSet.getBytes(
at org.postgresql.jdbc.PgResultSet.getBinaryStream(
at org.apache.commons.dbcp2.DelegatingResultSet.getBinaryStream(
at org.apache.commons.dbcp2.DelegatingResultSet.getBinaryStream(
at org.sonar.db.ce.CeTaskInputDao.selectData(
at org.sonar.ce.task.projectanalysis.step.ExtractReportStep.execute(
at org.sonar.ce.task.step.ComputationStepExecutor.executeStep(
at org.sonar.ce.task.step.ComputationStepExecutor.executeSteps(
at org.sonar.ce.task.step.ComputationStepExecutor.execute(
at org.sonar.ce.task.projectanalysis.taskprocessor.ReportTaskProcessor.process(
at org.sonar.ce.taskprocessor.CeWorkerImpl$ExecuteTask.executeTask(
at org.sonar.ce.taskprocessor.CeWorkerImpl$
at org.sonar.ce.taskprocessor.CeWorkerImpl.findAndProcessTask(
at org.sonar.ce.taskprocessor.CeWorkerImpl$$Lambda$785/222434688.apply(Unknown Source)
at org.sonar.ce.taskprocessor.CeWorkerImpl$TrackRunningState.get(
at java.util.concurrent.Executors$
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(
at java.util.concurrent.ScheduledThreadPoolExecutor$
at java.util.concurrent.ThreadPoolExecutor.runWorker(
at java.util.concurrent.ThreadPoolExecutor$

sonarqube version- 7.6
sonar-scanner version - sonar-scanner-
database used is postgres 9.6

I have increated the java memory under sonar scanner. properities file and gave the value as

also under the sonar properities the memory has been set to below
sonar.web.javaOpts =-Xmx8512m -Xms512m -XX:MaxPermSize=8192m -XX:+HeapDumpOnOutOfMemoryError

the AUTOCOMMIT is set to off under postgres sql.

still the repport is not gettign uploaded

end output of teh scanner execution is pasted below for referrence
WARN: Too many duplication groups on file thirdparty/private/cavium/usbc_gnu_src/OCTEON-SDK/bootloader/u-boot/arch/mips/cpu/octeon/cvmx/cvmx-error-init-cn52xxp1.c. Keep only the first 100 groups.
WARN: Too many duplication groups on file thirdparty/private/cavium/usbc_gnu_src/OCTEON-SDK/executive/cvmx-error-init-cn52xxp1.c. Keep only the first 100 groups.
INFO: CPD calculation finished
INFO: Analysis report generated in 12841ms, dir size=755 MB
INFO: Analysis report compressed in 43136ms, zip size=154 MB
INFO: Analysis report uploaded in 9079ms
INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=npsoft
INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AWly1M_sEQFv3_feQfsg
INFO: Executing post-job ‘Final report’
WARN: Preprocessor: 104132 include directive error(s). This is only relevant if parser creates syntax errors. The preprocessor searches for include files in the with ‘sonar.cxx.includeDirectories’ defined directories and order.
WARN: Source code parser: 167360 syntax error(s) detected. Syntax errors could cause invalid software metric values. Root cause are typically missing includes, missing macros or compiler specific extensions.
INFO: Turn debug info on to get more details (sonar-scanner -X -Dsonar.verbose=true …).
INFO: Analysis total time: 25:02.746 s
INFO: ------------------------------------------------------------------------
INFO: ------------------------------------------------------------------------
INFO: Total time: 25:04.835s
INFO: Final Memory: 108M/5898M
INFO: ------------------------------------------------------------------------

Could you please assist in resolving the java heap space error. Please let me knwo which all files needs to be verified or make chaneges

Sathish Krishnan

Hi Sathish,

This statement is contradictory. If the analysis report isn’t being uploaded, then you don’t get to the point of having a background task error. Based on the stacktrace, it seems that your memory problem is on the server side, not the scanner side. You should try increasing the server’s memory allocation (and restarting the server).