如何解决Sonarqube java.lang.OutOfMemoryError:Java堆空间

时间:2018-07-17 12:36:19

标签: sonarqube sonarqube-scan sonarqube-ops sonarqube-web

我正在使用Sonarqube社区版本。我遇到以下错误,

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

我已经更改了sonar.properties的大小,但仍然面临着同样的问题。如何解决这个问题。

sonar.web.javaOpts=-Xmx4G -Xms2048m -XX:+HeapDumpOnOutOfMemoryError
sonar.ce.javaOpts =-Xmx4G -Xms2048m -XX:+HeapDumpOnOutOfMemoryError 
sonar.search.javaOpts=-Xmx4G -Xms2048m -XX:+HeapDumpOnOutOfMemoryError

2 个答案:

答案 0 :(得分:1)

您所做的更改是将内存分配给SonarQube本身的设置。

您需要更改的设置是为分析过程分配内存。您尚未说明要使用哪个分析仪,因此详细信息会有所不同,但是

  • 用于SonarQube扫描仪export SONAR_SCANNER_OPTS="-Xmx512m"
  • 用于Maven export MAVEN_OPTS="-Xmx512m"的SonarQube扫描仪

答案 1 :(得分:0)

Project中的大文件导致了此问题,对我来说,一个50MB的XML文件给出了此错误,并且此文件对分析过程并不重要。我将此文件排除在配置文件(SonarQube.Analysis.xml)中,问题已解决