Set the permgen size for the Child JVM processes that Maven will spin off
Asked Answered
K

3

11

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.

Kingcup answered 31/10, 2012 at 15:27 Comment(0)
E
7

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.

Extraterrestrial answered 4/11, 2012 at 10:8 Comment(3)
We tried setting argLine, but it didn't work when we ran mvn gae:run, which is the maven-gae-plugin.Kingcup
Looking at the source code of maven-gae-plugin, have you tried its jvmFlags parameter?Extraterrestrial
I ran into this same problem recently, so I tried your suggestion about setting the jvmFlags parameter...and it worked like a charm! My problem was that we set the <argLine> tag in the configuration for maven-gae-plugin, but we should've used <jvmFlags> all along. Thank you!Kingcup
L
1

You can configure vm options globally (settings) and override it for any build job. E.g. in Maven based jobs, the MAVEN_OPTS field is hidden in one of the "advanced" blocks.

Lyon answered 31/10, 2012 at 15:39 Comment(0)
S
1

As mentioned previously by another reply that every process has its own way of specifying arguments. In case of maven sub process spawned by Jenkins the setting will be in the job configuration under the maven build. You need to click "Advanced" button and set the option in MAVEN_OPTS field. eg : -XX:MaxPermSize=256m -Xms512m -Xmx1024m

Superabundant answered 29/11, 2012 at 18:34 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.