How to configure Maven tests with more Java heap space?

Solution Verified - Updated -

Environment

  • maven-surefire-plugin, all versions
  • Maven, all versions

Issue

How to configure Maven test runs with more Java heap space?

Can an individual Java heap space be configured for Maven the tests?

Resolution

An individual Java heap space can be configured for any Maven tests by configuring the maven-surefire-plugin as follows:

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

Notice the JVMs maximum heap size configuration. Other JVM properties can be passed in as well using the configuration.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments