For the past few days I was wondering why Maven’s install gave me a Heap Overflow exception on JUnit tests on some of my machines. I tried increasing the memory by using the environment variable MAVEN_OPTS, by passing the option “-Xmx512m” to the JVM through Eclipse and from the command line. All to no avail.
Then I found this blog entry by Keith Chapman. And it worked! Here’s the solution in short:
The JUnit tests ignore the environment variable MAVEN_OPTS. You have to tell Maven’s surefire plugin to increase memory. Add this to your pom.xml file: [sourcecode language=‘xml’]
pertest -Xms512m -Xmx512m false false