简体   繁体   中英

PermGen errors in Jenkins

I had cases of Jenkins failures and nothing but Jenkins redeployment (Jenkins is a webapp in Tomcat) helped. Even new jobs failed with PermGen space errors, but all the settings were fine (all these -XX:PermSize parameters everywhere it's possible). The point is after redeployment everything worked like a charm. But it's a harsh solution. I wanted to know, if there are some options to rollback Jenkins state. Thanks in advance.

Update : Okay, for those, who may face something like that, here is what I figured out. Those, who wrote that it's better to deploy Jenkins as a Tomcat module probably didn't face the problems of any kind of project deployment (with Jenkins Deploy plugin or with a tomcat-maven-plugin in Maven's pom.xml ). I didn't have any of the problems I described when installed Jenkins separately. Whew!

The one setting that really matters for PermGen space errors is (and it must be this exactly ):

-XX:MaxPermSize=512m

One dash, two Big Xs, Big-M, Big-P, Big-S, no-spaces, size-in-megs, lower case m. If you screw it up it will be ignored. 99% of all the PermGen fixes I see that "don't work" are because someone didn't follow instructions precisely and used a Big-M for megabytes instead of a little-m, or put two dashes in front instead of one for example.

Also, 512 megs is just a starting point... adjust to fit your system.

I once experienced similar errors: jenkins was executing maven builds, which included surefire tests execution. I discovered that the version of maven I was using (V2 something) did not pass my JVM memory options to the surefire process fork, and some tests were failing because of this. MAVEN_OPTS, JAVA_OPTS, none did work.

I ended up passing my memory options directly in the settings.xml, and the PermGen errors were gone.

Here are the options I used (the app was fairly big):

-Xms512m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=1024m

Completely untested suggestion, but this answer suggests using -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled when starting Tomcat (albeit for an issue in a completely different context). This answer , however, suggests that CMSPermGenSweepingEnabled is unnecessary on Java 6 and that -XX:+UseConcMarkSweepGC must be used for CMSClassUnloadingEnabled to be effective.

At the very least -XX:+CMSClassUnloadingEnabled may do the trick assuming that the underlying issue is caused by classes being unnecessarily maintained in the PermGen space for your Tomcat instance.

maybe this question can help you:

How to give Jenkins more heap space when it´s started as a service under Windows?

There are some very good answers there.

I found bumping the JRE to Java 8 helped. By default Jenkins uses the JRE under the home folder, invoked by the jenkins.xml task

我通过添加到jenkins.conf解决了Linux中的PermGen错误:

wrapper.java.additional.4=-XX:PermSize=1024M

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM