Category: Tools

Maven Java heap space error

My build fails with an java.lang.OutOfMemoryError: Java heap space error

When this occurs during the unit test phase of your project this typically has something to do with Surefire. Surefire forks a new JVM process to start the unittests. This process does not inherit the JVM arguments like memory and maxpermgen size. You can manually add it to the surefire plugin for your project.

<plugin>
 <groupid>org.apache.maven.plugins</groupId>
 <artifactid>maven-surefire-plugin</artifactId>
 <version>2.6</version>
 <configuration>
  <argline>-Xms512m -Xmx1024m -XX:MaxPermSize=512m</argLine>
 </configuration>
</plugin>

Make sure you only do this when you indeed experience memory problems in your build.

Eclipse rox!

Euhm, what do I have to do to Accept and Finish? ;-)