Skip to content

OutOfMemoryError and GC overhead limit in Maven’s surefire plugin – How to resolve?

When you run into OutOfMemoryError when running unit tests in Maven, you have to set the Java Heap Memory in the maven-surefire-plugin inside the pom.xml.

Advertisements

Surefire usually runs in a own VM which does not use maven opts memory settings.

See here for how to adjust surefire memory settings: surefire plugin

So what you would have to do is to basically change your pom.xml to set memory settings for the surefire plugin.

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>3.7</version>
    <configuration>
        <argLine>-Xms512m -Xmx512m</argLine>
    </configuration>
</plugin>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.