How to configure Maven tests with more Java heap space?

Solution Verified - Updated -


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


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

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


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


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.



All Supported Operating Systems




The Maven shell environment variable MAVEN_OPTS which can be used to configure the Java heap for Maven itself is not used when creating a JVM to run the Maven tests. So whatever JVM arguments are in MAVEN_OPTS, these will not be passed on to the JVM running the tests itself!
Also see the Maven Surefire Plugin [documentation](