Saturday, December 24, 2011

Maven tips: Fixing OutOfMemoryError

Refer: https://cwiki.apache.org/confluence/display/MAVEN/OutOfMemoryError
Simple as setting MAVEN_OPTS variable on your environment.

MAVEN_OPTS="-Xmx512m -XX:MaxPermSize=128m"
 
A widely known problem & a solution. Just adding a reference to Maven documentation for my future reference & anyone else's.

What I did not know before is following part.
"When using the Java compiler in embedded mode, each compiled class will consume heap memory and depending on the JDK being used this memory is not subject to gargabe collection, i.e. the memory allocated for the compiled classes will not be freed"

If your using 'maven-compiler-plugin' this can be set using pom.xml of your project as well.
Refer: http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-with-memory-enhancements.html

0 comments: