15

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!

John Doe
  • 9,414
  • 13
  • 50
  • 69
  • are you running under ubuntu? if yes, you need to override /etc/default/tomcat settings. Otherwise you could try to run tomcat with Jrockit JVM that does not suffer from permgenspace issues. – jocelyn Jun 21 '12 at 12:04
  • @jocelyn Yep, it's Ubuntu, and I tried to override those settings. Jrockit may be a solution, still it's a bit strange to change JVM because of Jenkins. – John Doe Jun 21 '12 at 12:07

6 Answers6

34

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.

Matt Brock
  • 5,337
  • 1
  • 27
  • 26
6

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

Dominique Eav
  • 195
  • 1
  • 1
  • 7
  • 1
    Thanks, maybe I'll need that, but in my case PermGen always appeared at the very beginning, not while performing tests or something else. – John Doe Jun 21 '12 at 12:59
4

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.

Community
  • 1
  • 1
ig0774
  • 39,669
  • 3
  • 55
  • 57
1

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.

Community
  • 1
  • 1
Eduardo Andrade
  • 946
  • 7
  • 10
0

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

N00b Pr0grammer
  • 4,503
  • 5
  • 32
  • 46
0

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

wrapper.java.additional.4=-XX:PermSize=1024M
Jan B.
  • 6,030
  • 5
  • 32
  • 53