Maven Surefire PermGen error

In case you are getting PermGen error while running tests using the Maven Surefire plugin, here is the solution:

<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-surefire-plugin</artifactId>
  <version>${surefire.version}</version>
  <configuration>
    <argLine>-Xmx512m -XX:MaxPermSize=256m</argLine>
  </configuration>
</plugin>

Setting the JVM args as part of the plugin did the trick!

Setting MAVEN_OPTS would not help because Maven Surefire plugin forks the JVM process while running the tests, and so the MAVEN_OPTS settings do not take effect.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: