【问题标题】:Memory error when running unit tests in SonarQube -- forked VM terminated without saying properly goodbye在 SonarQube 中运行单元测试时出现内存错误——分叉的虚拟机在没有正确告别的情况下终止
【发布时间】:2014-08-15 09:33:33
【问题描述】:

在运行声纳分析时,我们不断出现内存不足错误。它在机器之间是间歇性的,但似乎一旦你得到它,它就会持续存在。

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.16:test   (default-cli) on project optimus-client-web-configuration: Execution default-cli of goal org.apache.maven.plugins:    

maven-surefire-plugin:2.16:test failed: The forked VM terminated without saying properly goodbye. VM crash or System.exit called ?
[ERROR] Command wascmd.exe /X /C ""C:\Program Files\Java\jdk1.7.0_45\jre\bin\java" -javaagent:C:\Users\cxxx\AppData\Local\Temp\jacocoagent8301608889470684052.jar=destfile=target/jacoco.exec,excludes=
*_javassist_* -jar C:\redesign_Trunk\optimus-lms-server\optimus-client-web-configuration\target\surefire\surefirebooter2312966376869893038.jar C:\redesign_Trunk\optimus-lms-server\optimus-client-web-con
figuration\target\surefire\surefire350975689095180011tmp C:\redesign_Trunk\xxx-xx-server\xxx\target\surefire\surefire_45613339175612175619tmp"

在声纳阶段之前运行时,单元测试不会因此而失败。它发生在一项特定的测试中,该测试激活了 Spring 配置以测试它是否可以正常工作。由于必须加载整个上下文,因此该测试可能比大多数测试消耗更多的内存。

我增加了 MAVEN_OPTS 中的内存以使用 1024M 最大堆。将此配置添加到我的 pom 中

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.16</version>
                <configuration>
                    <argLine>-Xmx1024m</argLine>
                </configuration>
</plugin>

【问题讨论】:

    标签: java maven out-of-memory sonarqube maven-surefire-plugin


    【解决方案1】:

    另一种解决方案:以管理员身份运行应用程序 [Eclipse IDE, SonarQube...]

    问题:
    1. 当错误日志包含:'... VM 在没有正确告别的情况下终止...'
    2. 错误日志包含:“cmd.exe /C ... error something ...”
    3. 错误日志包含:'... java.io.tmpdir ... c:\windows'

    【讨论】:

      【解决方案2】:

      在此配置中,您只是将surefire插件配置为在生成新jvm时使用此内存,您还需要为mvn的jvm增加内存

      export MAVEN_OPTS="-Xmx2048m"
      

      尝试以上(使用适当的内存大小)

      【讨论】:

      • 要直接在 Maven 命令中执行此操作,请将其添加到 argLine 参数中,如下所示:mvn -DargLine="-Xmx2048m" {... rest of maven arguments}
      猜你喜欢
      • 1970-01-01
      • 2018-03-31
      • 2014-06-09
      • 2023-01-09
      • 1970-01-01
      • 1970-01-01
      • 2012-12-22
      相关资源
      最近更新 更多