3

I'm using Sonarqube community version. I'm getting the following error,

Exception in thread "LOG_FLUSHER" Exception in thread "CHECKPOINT_WRITER" java.lang.OutOfMemoryError: Java heap space
        at java.util.ArrayList.iterator(ArrayList.java:840)
        at java.util.Collections$SynchronizedCollection.iterator(Collections.java:2031)
        at com.persistit.Persistit.pollAlertMonitors(Persistit.java:2285)
        at com.persistit.Persistit$LogFlusher.run(Persistit.java:192)
java.lang.OutOfMemoryError: Java heap space
        at java.util.HashMap$Values.iterator(HashMap.java:968)
        at com.persistit.Persistit.earliestDirtyTimestamp(Persistit.java:1439)
        at com.persistit.CheckpointManager.pollFlushCheckpoint(CheckpointManager.java:271)
        at com.persistit.CheckpointManager.runTask(CheckpointManager.java:301)
        at com.persistit.IOTaskRunnable.run(IOTaskRunnable.java:144)
        at java.lang.Thread.run(Thread.java:748)
WARNING: WARN: [JOURNAL_FLUSHER] WARNING Journal flush operation took 7,078ms last 8 cycles average is 884ms
INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 1:17.852s
ERROR: Error during SonarQube Scanner execution
ERROR: Java heap space
ERROR:

Exception: java.lang.OutOfMemoryError thrown from the UncaughtExceptionHandler in thread "CLEANUP_MANAGER"
INFO: Final Memory: 40M/989M
INFO: ------------------------------------------------------------------------
The SonarQube Scanner did not complete successfully

I have Changed the size in sonar.properties, still I'm facing the same problem. How to solve this.

sonar.web.javaOpts=-Xmx4G -Xms2048m -XX:+HeapDumpOnOutOfMemoryError
sonar.ce.javaOpts =-Xmx4G -Xms2048m -XX:+HeapDumpOnOutOfMemoryError 
sonar.search.javaOpts=-Xmx4G -Xms2048m -XX:+HeapDumpOnOutOfMemoryError
Vijayadhiliban
  • 41
  • 1
  • 2
  • 6

3 Answers3

9

What you've changed are the settings that allocate memory to SonarQube itself.

What you need to change is the setting that allocates memory to the analysis process. You haven't said which analyzer you're using, so the details will vary a little, but

  • for SonarQube Scanner export SONAR_SCANNER_OPTS="-Xmx512m"
  • for SonarQube Scanner for Maven export MAVEN_OPTS="-Xmx512m"
G. Ann - SonarSource Team
  • 22,346
  • 4
  • 40
  • 76
1

Large files in Project cause this problem, for me a 50MB XML file gives this error and this file was not important to the analysis process. I excluded this file in the configuration file (SonarQube.Analysis.xml) and the problem was solved

Danial Delkhosh
  • 147
  • 1
  • 9
1

Try narrowing the scope of files to be scanned/analyzed with the following Analysis Properties. pointing the sources directly to the SRC path from Workspace, will avoid other unwanted files and can consume very little memory. or add exclusions of Large Sized files.

sonar.language=java
sonar.sources=Proj1/sub1/src
sonar.java.binaries=.
sonar.exclusions=**/*.docx,**/*.zip,**/*.ear

Also, try with the following Java memory or Heap Memory Options individually.

sonar.web.javaOpts=-Xmx1024m -Xms512m
sonar.web.javaOpts=-Xmx1024m -Xms512m -XX:+HeapDumpOnOutOfMemoryError
sonar.ce.javaOpts=-Xmx2048m -Xms512m
sonar.ce.javaOpts=-Xmx12g -Xms3g -XX:+HeapDumpOnOutOfMemoryError

Also, try updating the Environmental Variables below

ANT_OPTS=-Xms512m -Xmx1800m
SONAR_SCANNER_OPTS=-Xmx1024m -Xms512m
SONAR_RUNNER_OPTS=-Xmx1024m -XX:MaxPermSize=512m

All the above properties can also be added in the "$SONARQUBE_HOME/conf/sonar.properties" file.

Raghav Tallam
  • 581
  • 4
  • 8