John Doe
John Doe

Reputation: 9764

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!

Upvotes: 15

Views: 29117

Answers (6)

AchiazD
AchiazD

Reputation: 1

I resolved PermGen error in Linux by adding to jenkins.conf:

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

Upvotes: 0

Tim Prentice
Tim Prentice

Reputation: 1

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

Upvotes: 0

Matt Brock
Matt Brock

Reputation: 5401

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.

Upvotes: 34

ig0774
ig0774

Reputation: 41287

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.

Upvotes: 4

Dominique Eav
Dominique Eav

Reputation: 305

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

Upvotes: 6

Eduardo Andrade
Eduardo Andrade

Reputation: 966

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.

Upvotes: 1

Related Questions