java.lang.OutOfMemoryError - Java heap space

Template for a good bug report, formatted with Markdown:

  • versions used (SonarQube, Scanner, Plugin, and any relevant extension)
    8.9.1

  • error observed (wrap logs/code around triple quote ``` for proper formatting)
    [sonar:sonar] Dependencies/libraries were not provided for analysis of TEST files. The ‘sonar.java.test.libraries’ property is empty. Verify your configuration, as you might end up with less precise results.
    [sonar:sonar] Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.
    [sonar:sonar] Java Main Files AST scan (done) | time=45499ms
    [sonar:sonar] Java Test Files AST scan
    [sonar:sonar] 145 source files to be analyzed
    [sonar:sonar] Invalid character encountered in file D:/fea/hybris/bin/ext-tui/endecasearch/testsrc/uk/co/portaltech/travel/thirdparty/endeca/test/stubs/EndecaResponseStubs.java at line 64 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
    [sonar:sonar] Invalid character encountered in file D:/fea/hybris/bin/ext-tui/endecasearch/testsrc/uk/co/portaltech/travel/thirdparty/endeca/test/stubs/EndecaResponseStubsTest.java at line 90 for encoding UTF-8. Please fix file content or configure the encoding to be used using property ‘sonar.sourceEncoding’.
    [sonar:sonar] Unresolved imports/types have been detected during analysis. Enable DEBUG mode to see them.

  • steps to reproduce

Using ant target to upload the coverage and analysis.

scanner version - sonar-scanner-engine-shaded-8.9.1.44547-all.jar

while scanning the coverage xml Sonar Qube the error has been observed. Increased the heap memory for CE to12 GB but still its failing with the above error.
sonar.ce.javaOpts=-Xmx12g -Xms3g -XX:+HeapDumpOnOutOfMemoryError

It will be good to know any property change to fix the problem.

  • potential workaround
    No

P.S.: use the #bug:fault sub-category if you’re hitting a specific crash/error , or the #bug:fp sub-category for rules-related behaviour

Hi @CodingManager
your report seems to be for a Java heap space problem on the analysis side, while the sonar.ce.javaOpts parameter is for the server side (memory allocated to the Compute Engine component of your SonarQube server).
And you may increase the maven maximum heap size with the MAVEN_OPTS environment variable as described here in the SonarScanner for Maven documentation page.
Let me know.

@Sylvain_Combe - Hi Thanks for your reply. I am using ANT script in the project. As per you we need to increase the memory in the build tool not in SonarQube.

Is that my understanding correct?

Hi @CodingManager
yes you are right, you need to add some memory space to the JVM running the analysis on the project build side. I saw some sonar:sonar marker in the logs you provided and thought you were using Maven.

If you’re using ant to run the analysis, you may use ANT_OPTS. Or if you are using the command line scanner, you may use the SONAR_SCANNER_OPTS environment variable.

@Sylvain_Combe - Thank you for the help. Yes its fixed the problem.

1 Like

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