I am building a Maven Java app on a Jenkins build server. I am running into java.lang.OutOfMemoryError: PermGen space
many times during the build on Jenkins (but never on my localhost) and hence it fails my build.
I have already tried setting MAVEN_OPTS
for Jenkins: I went into Jenkins
-->Manage Jenkins
-->Configure system
-->Global MAVEN_OPTS
and it was set to -Xms512m -Xmx1024m -XX:MaxPermSize=512m -XX:PermSize=512m
. Despite setting it to this high value, we keep running into the PermGen space issues. I don't want to set the MAVEN_OPTS to a higher value; I do not see how my app can require a gig of space, and I'd rather dig deep into the high-memory-usage problem.
Lately, I've been thinking that perhaps the permgen space issue is NOT coming from Maven itself but rather one of the JVM processes that Maven spins off (ex: plugins). I propose this hypothesis because Maven is still able to execute TestNG tests alright, despite already spitting our the permgen space error lines. One such plugin that is causing the PermGen error is Jetty:
Oct 31, 2012 7:55:37 AM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: handle failed
java.lang.OutOfMemoryError: PermGen space
Hence, I would like to know:
Does the MAVEN_OPTS
variable also apply to child JVM processes that a Maven build spins off? If not, then how do I set the JVM options for these child processes such as Jetty?
NOTE: I am using Maven 3.0.4.
Most Maven plugins that spawn Java processes will have their own way of specifying JVM command line arguments. For example, you can configure heap and permgen sizes in processes spawned by the Surefire plugin using the argLine
configuration parameter (see http://maven.apache.org/plugins/maven-surefire-plugin/test-mojo.html#argLine).
The Jetty plugin doesn't spawn processes, so heap and permgen are governed by JVM arguments provided to the Maven process.
If you are running out of memory when running from Jenkins but not when running locally, check the MAVEN_OPTS that Jenkins passes to Maven.