Reputation: 37993
I have a multi-module Maven project with two modules being Spring Boot applications. Each of them has a simple test that the Spring application context loads successfully (my tests are very similar to this one). I run this tests with the following command in project root:
mvn -P IntegrationTests clean test
During context initialization things go out of my control, the application "eats" memory (heap size grows quickly to 4 gigabytes) and then the context fails to start with java.lang.OutOfMemoryError: PermGen space
error (yes, I run it in Java 7).
Monitoring task manager during testing I noticed that maven spawns two new processes that have something to do with surefire plugin. I have no idea where it comes from, because I don't add the surefire plugin in my pom.xml.
Previously when encountered the same error somewhere I specified VM options (-Xmx256m -Xms128m -XX:MaxPermSize=256m -XX:PermSize=128m
for example) and the problem was solved.
This time I tried to
MAVEN_OPTS
environment variablemvn test
in IntelliJ IDEA) - it affected main java process but not its children-Drun.jvmArguments="..."
in command linebut the problem persists.
Please help me to fight the OutOfMemoryError
in tests.
Upvotes: 0
Views: 1346
Reputation: 37993
Add Surefire plugin explicitly to module-specific pom.xml and configure VM options there. I like this solution because this way VM options are
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>-Xmx256m -Xms128m -XX:MaxPermSize=256m -XX:PermSize=128m</argLine>
</configuration>
</plugin>
<!-- your other plugins go here -->
</plugins>
</build>
Upvotes: 0