surefire HeapDumpOnOutOfMemoryError
Asked Answered
P

4

7

When running my unit tests in Maven on windows i'm getting an OutOfMemory exception. I tried to add -XX:-HeapDumpOnOutOfMemoryError option to the surefire argLine, but no dump file is generated. I also tried to add the same thing to MAVEN_OPTS, but still nothing, I simply get an OutOfMemory exception and the process hangs until I manually kill it.

My pom is as follows:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
    <configuration>                    
        <testFailureIgnore>false</testFailureIgnore>
        <argLine>-Xms512m -Xmx512m -XX:PermSize=256m -XX:-HeapDumpOnOutOfMemoryError</argLine>
        <forkMode>once</forkMode>            
    </configuration>
</plugin>

MAVEN_OPTS:

set MAVEN_OPTS=-XX:-HeapDumpOnOutOfMemoryError

Do you have any idea why no dump file is generated?

Polyhydroxy answered 4/1, 2011 at 18:12 Comment(1)
The answer from @twillouer is the correct one.Richrichara
B
5

You're using "-" to disable the option. Use "+" to enable it:

<argLine>... -XX:+HeapDumpOnOutOfMemoryError</argLine>
                 ^ 
Broadleaved answered 12/4, 2018 at 7:52 Comment(0)
S
2

Try this:

set MAVEN_OPTS="-Dmaven.surefire.debug=\"-XX:-HeapDumpOnOutOfMemoryError\""
Stereotypy answered 6/1, 2011 at 2:27 Comment(1)
Still nothing. I don't see any output. I managed to find the memory leak by connecting using a profiler, so thanks anyway for your response.Polyhydroxy
A
1

Your memory leak might just be fixed, see http://jira.codehaus.org/browse/SUREFIRE-495. You may want to try surefire 2.7.1 or newer.

Aramen answered 11/1, 2011 at 17:2 Comment(1)
Thanks for you reply, but my problem isn't related to surefire. I use spring in my tests and I have different application contexts for the same beans over and over again. Because spring caches application contexts for performance reasons none for them got destroyed and I get the OutOfMemory error. The fix is to change my tests to use the same contexts instead of duplicating them in different contexts.Polyhydroxy
S
0

I think you forget the path :

    <argLine>-Xms512m -Xmx512m -XX:PermSize=256m -XX:-HeapDumpOnOutOfMemoryError  -XX:HeapDumpPath=/tmp</argLine>

with this argument :

     -XX:HeapDumpPath=/tmp
Sufficient answered 7/1, 2014 at 8:48 Comment(1)
This is not necessary. Heap dump is created by default in project directory (I launch Maven via Netbeans). When would it be necessary? When would the current directory be different (and non-writeable)?Whereupon

© 2022 - 2024 — McMap. All rights reserved.