surefire HeapDumpOnOutOfMemoryError

Kob*_*oby 6 out-of-memory surefire maven

当在Windows上的Maven中运行我的单元测试时,我得到一个OutOfMemory异常.我尝试将-XX:-HeapDumpOnOutOfMemoryError选项添加到surefire argLine,但是没有生成转储文件.我也尝试向MAVEN_OPTS添加相同的东西,但仍然没有,我只是得到一个OutOfMemory异常并且该过程挂起,直到我手动杀死它.

我的pom如下:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>                    
        <testFailureIgnore>false</testFailureIgnore>
        <argLine>-Xms512m -Xmx512m -XX:PermSize=256m -XX:-HeapDumpOnOutOfMemoryError</argLine>
        <forkMode>once</forkMode>            
    </configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)

MAVEN_OPTS:

set MAVEN_OPTS=-XX:-HeapDumpOnOutOfMemoryError
Run Code Online (Sandbox Code Playgroud)

你知道为什么没有生成转储文件吗?

Aar*_*lla 5

您正在使用“-”禁用该选项。使用“+”启用它:

<argLine>... -XX:+HeapDumpOnOutOfMemoryError</argLine>
                 ^ 
Run Code Online (Sandbox Code Playgroud)


Bri*_*ing 2

尝试这个:

set MAVEN_OPTS="-Dmaven.surefire.debug=\"-XX:-HeapDumpOnOutOfMemoryError\""
Run Code Online (Sandbox Code Playgroud)