Maven spotbugs插件因内存不足错误而失败

时间:2017-12-06 19:40:44

标签: java maven java-8 findbugs spotbugs

我正在尝试使用如下所示的spotbugs-maven-plugin

<build>
...
<plugin>
        <groupId>com.github.spotbugs</groupId>
        <artifactId>spotbugs-maven-plugin</artifactId>
        <version>3.1.0-RC8</version>
        <configuration>
                <plugins>
                        <plugin>
                            <groupId>jp.skypencil.findbugs.slf4j<groupId>
                            <artifactId>bug-pattern</artifactId>
                            <version>1.2.4</version>
                        </plugin>
                </plugins>
                <includeFilterFile>./spotbugIncludeFilter.xml</includeFilterFile>
                <onlyAnalyze>com.vnera.-</onlyAnalyze>
                <argLine>-Xmx1024m</argLine>
        </configuration>
</plugin>
</build>

但每次失败都会出现以下错误

[INFO] Fork Value is true
     [java] Out of memory
     [java] Total memory: 482M
     [java]  free memory: 43M

Stacktrace如下所示

[java]  at java.util.ArrayList.<init>(ArrayList.java:152)
[java]     at edu.umd.cs.findbugs.ba.Frame.<init>(Frame.java:113)
[java]     at edu.umd.cs.findbugs.ba.vna.ValueNumberFrame.<init>(ValueNumberFrame.java:90)
[java]     at edu.umd.cs.findbugs.ba.vna.ValueNumberAnalysis.createFact(ValueNumberAnalysis.java:181)
[java]     at edu.umd.cs.findbugs.ba.vna.ValueNumberAnalysis.createFact(ValueNumberAnalysis.java:58)
[java]     at edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis.lookupOrCreateFact(BasicAbstractDataflowAnalysis.java:185)
[java]     at edu.umd.cs.findbugs.ba.BasicAbstractDataflowAnalysis.getStartFact(BasicAbstractDataflowAnalysis.java:70)
[java]     at edu.umd.cs.findbugs.ba.Dataflow.execute(Dataflow.java:234)
[java]     at edu.umd.cs.findbugs.classfile.engine.bcel.ValueNumberDataflowFactory.analyze(ValueNumberDataflowFactory.java:76)
[java]     at edu.umd.cs.findbugs.classfile.engine.bcel.ValueNumberDataflowFactory.analyze(ValueNumberDataflowFactory.java:46)
[java]     at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.analyzeMethod(AnalysisCache.java:369)
[java]     at edu.umd.cs.findbugs.classfile.impl.AnalysisCache.getMethodAnalysis(AnalysisCache.java:322)
[java]     at edu.umd.cs.findbugs.ba.ClassContext.getMethodAnalysis(ClassContext.java:1005)
[java]     at edu.umd.cs.findbugs.ba.ClassContext.getValueNumberDataflow(ClassContext.java:336)
[java]     at edu.umd.cs.findbugs.detect.FindInconsistentSync2.analyzeMethod(FindInconsistentSync2.java:638)
[java]     at edu.umd.cs.findbugs.detect.FindInconsistentSync2.visitClassContext(FindInconsistentSync2.java:413)
[java]     at edu.umd.cs.findbugs.DetectorToDetector2Adapter.visitClass(DetectorToDetector2Adapter.java:76)
[java]     at edu.umd.cs.findbugs.FindBugs2.analyzeApplication(FindBugs2.java:1079)
[java]     at edu.umd.cs.findbugs.FindBugs2.execute(FindBugs2.java:280)
[java]     at edu.umd.cs.findbugs.FindBugs.runMain(FindBugs.java:401)
[java]     at edu.umd.cs.findbugs.FindBugs2.main(FindBugs2.java:1187)

我也尝试过设置<argLine>-XX:MaxPermSize=1024m</argLine>。仍然得到同样的错误。

有人可以告诉我如何解决这个问题?

  • Java 8
  • Maven 3

1 个答案:

答案 0 :(得分:4)

你看过maxHeap了吗?这应该有助于增加你的内存问题。

同样来自他们的FAQ声明:

  

您可以使用-maxHeap n选项增加此值,其中n是   要分配的堆空间的兆字节数。