在SonarQube中运行单元测试时出现内存错误——分叉的虚拟机没有正确地说再见就终止了



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

[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 FilesJavajdk1.7.0_45jrebinjava" -javaagent:C:UserscxxxAppDataLocalTempjacocoagent8301608889470684052.jar=destfile=target/jacoco.exec,excludes=
*_javassist_* -jar C:redesign_Trunkoptimus-lms-serveroptimus-client-web-configurationtargetsurefiresurefirebooter2312966376869893038.jar C:redesign_Trunkoptimus-lms-serveroptimus-client-web-con
figurationtargetsurefiresurefire350975689095180011tmp C:redesign_Trunkxxx-xx-serverxxxtargetsurefiresurefire_45613339175612175619tmp"

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

我提高内存在MAVEN_OPTS使用1024M最大堆。将此配置添加到my pom

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

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

export MAVEN_OPTS="-Xmx2048m"

另一个解决方案:运行应用程序[Eclipse IDE, SonarQube…]作为管理员

问题:
1. 当错误日志包含:'…
虚拟机在没有正确道别的情况下被终止…2. 错误日志包含:"cmd.exe/C…"错误…"
3.错误日志包含:'… . io .tmpdir c: windows

相关内容

最新更新