We used Maven2 as the build tool on the project.
I tried various things to fix it but without luck.
A few of those were:
- Setting the MAVEN_OPTS=-Xms512m -Xmx1024m -XX:MaxPermSize=512m
- Setting the JVM_OPTS=-Xms512m -Xmx1024m -XX:MaxPermSize=512m
- Trying the <maxmem> property of cobertura in pom.xml
The real problem is surefire plug-in forks a new jvm to run the tests and this jvm does not seem to inherit the memory settings.
So what is the way around is?
We can use the argLine configuration property of the maven-surefire-plugin to bump up the memory.
The above code means:
- Initial java heap size is 512m
- Maximum java heap size is 1024m
- Maximum size of permanent generation heap is 512m.
All said and done, the real test is in the real world.
After those settings I ran mvn clean cobertura:cobertura and Yes, it worked!
No more OutOfMemoryError!
The sample pom.xml that I used is: