OutOfMemory - Sonar无法分析项目源代码,也无法找到问题

时间:2018-01-20 12:16:51

标签: java intellij-idea sonarqube sonarlint

我在IntelliJ Idea的Java项目中运行插件SonarLint。

当我请求整个项目的代码分析时,我收到以下消息:

SonarLint分析失败:Java堆空间

以下是日志:

Error running SonarLint analysis
java.lang.OutOfMemoryError: Java heap space



java.lang.OutOfMemoryError: Java heap space
    at java.util.Arrays.copyOf(Arrays.java:3181)
    at java.util.Vector.grow(Vector.java:266)
    at java.util.Vector.ensureCapacityHelper(Vector.java:246)
    at java.util.Vector.addElement(Vector.java:620)
    at com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM.addNode(DOM2DTM.java:247)
    at com.sun.org.apache.xml.internal.dtm.ref.dom2dtm.DOM2DTM.nextNode(DOM2DTM.java:543)
    at com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase._nextsib(DTMDefaultBase.java:567)
    at com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBase.getNextSibling(DTMDefaultBase.java:1142)
    at com.sun.org.apache.xml.internal.dtm.ref.DTMDefaultBaseTraversers$ChildTraverser.next(DTMDefaultBaseTraversers.java:465)
    at com.sun.org.apache.xpath.internal.axes.AxesWalker.getNextNode(AxesWalker.java:337)
    at com.sun.org.apache.xpath.internal.axes.AxesWalker.nextNode(AxesWalker.java:365)
    at com.sun.org.apache.xpath.internal.axes.WalkingIterator.nextNode(WalkingIterator.java:197)
    at com.sun.org.apache.xpath.internal.axes.NodeSequence.nextNode(NodeSequence.java:344)
    at com.sun.org.apache.xpath.internal.axes.NodeSequence.runTo(NodeSequence.java:503)
    at com.sun.org.apache.xml.internal.dtm.ref.DTMNodeList.<init>(DTMNodeList.java:83)
    at com.sun.org.apache.xpath.internal.objects.XNodeSet.nodelist(XNodeSet.java:348)
    at com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.getResultAsType(XPathExpressionImpl.java:364)
    at com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.eval(XPathExpressionImpl.java:110)
    at com.sun.org.apache.xpath.internal.jaxp.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:191)
    at org.sonar.java.xml.XmlCheckContextImpl.evaluate(XmlCheckContextImpl.java:82)
    at org.sonar.java.xml.XmlCheckContextImpl.evaluateOnDocument(XmlCheckContextImpl.java:76)
    at org.sonar.java.checks.xml.spring.SingleConnectionFactoryCheck.scanFileWithXPathExpressions(SingleConnectionFactoryCheck.java:45)
    at org.sonar.java.xml.XPathXmlCheck.scanFile(XPathXmlCheck.java:36)
    at org.sonar.java.xml.XmlAnalyzer.simpleScanAsXmlFile(XmlAnalyzer.java:107)
    at org.sonar.java.xml.XmlAnalyzer.simpleScan(XmlAnalyzer.java:97)
    at org.sonar.java.xml.XmlAnalyzer.scan(XmlAnalyzer.java:81)
    at org.sonar.plugins.java.XmlFileSensor.execute(XmlFileSensor.java:55)
    at org.sonarsource.sonarlint.core.analyzer.sensor.NewSensorsExecutor.executeSensor(NewSensorsExecutor.java:72)
    at org.sonarsource.sonarlint.core.analyzer.sensor.NewSensorsExecutor.execute(NewSensorsExecutor.java:63)
    at org.sonarsource.sonarlint.core.analyzer.sensor.PhaseExecutor.execute(PhaseExecutor.java:36)
    at org.sonarsource.sonarlint.core.container.analysis.AnalysisContainer.doAfterStart(AnalysisContainer.java:142)
    at org.sonarsource.sonarlint.core.container.ComponentContainer.startComponents(ComponentContainer.java:125)

如何增加内存?

1 个答案:

答案 0 :(得分:2)

Eclipse:Run - &gt; Run Configurations - &gt;然后在maven build - &gt;下选择项目然后选择标签“JRE” - &gt;然后输入-Xmx1024m

Run - &gt; Run Configurations - &gt;选择"JRE"标签 - &gt;然后输入-Xmx1024m

我建议你使用profiler检查你需要多少内存,这样你就不会分配太多内存。

我错过了IntelliJ Idea:

您可以获取信息here

请确保您在正确的位置增加堆。您需要在IDEA的Ant工具窗口中单击“属性”按钮,然后在那里编辑“最大堆大小(Mb)”字段。