简体   繁体   English

Jenkins中的PermGen错误

[英]PermGen errors in Jenkins

I had cases of Jenkins failures and nothing but Jenkins redeployment (Jenkins is a webapp in Tomcat) helped. 我有詹金斯失败的案例,除了Jenkins重新部署(Jenkins是Tomcat中的webapp)帮助。 Even new jobs failed with PermGen space errors, but all the settings were fine (all these -XX:PermSize parameters everywhere it's possible). 即使新的作业因PermGen空间错误而失败,但所有设置都很好(所有这些-XX:PermSize参数在任何地方都是可能的)。 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. 我想知道,如果有一些选项可以回滚Jenkins状态。 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 ). 那些写道,最好将Jenkins部署为Tomcat模块的人可能没有遇到任何类型项目部署的问题(使用Jenkins Deploy插件或在Maven的pom.xml使用tomcat-maven-plugin )。 I didn't have any of the problems I described when installed Jenkins separately. 当我分别安装Jenkins时,我没有遇到任何问题。 Whew! 呼!

The one setting that really matters for PermGen space errors is (and it must be this exactly ): 在一个设置,真正重要的PermGen space的错误,是(而且必须是这个完全一致 ):

-XX:MaxPermSize=512m

One dash, two Big Xs, Big-M, Big-P, Big-S, no-spaces, size-in-megs, lower case m. 一个短划线, 两个 Big X,Big-M,Big-P,Big-S,无空间,尺寸在megs, 小写 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. 在所有PermGen修复程序的99%中,我发现“不工作”是因为有人没有精确地遵循指令而使用Big-M代替兆字节,或者在前面放两个破折号而不是一个破折号例。

Also, 512 megs is just a starting point... adjust to fit your system. 此外,512兆只是一个起点...调整适合您的系统。

I once experienced similar errors: jenkins was executing maven builds, which included surefire tests execution. 我曾经遇到类似的错误:jenkins正在执行maven构建,其中包括surefire测试执行。 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版本(V2某些东西)没有将我的JVM内存选项传递给surefire进程fork,并且由于这个原因,一些测试失败了。 MAVEN_OPTS, JAVA_OPTS, none did work. MAVEN_OPTS,JAVA_OPTS,没有人工作。

I ended up passing my memory options directly in the settings.xml, and the PermGen errors were gone. 我最终直接在settings.xml中传递了我的内存选项,并且PermGen错误消失了。

Here are the options I used (the app was fairly big): 以下是我使用的选项(应用程序相当大):

-Xms512m -Xmx1024m -XX:PermSize=512m -XX:MaxPermSize=1024m -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). 完全未经测试的建议,但这个答案建议在启动Tomcat时使用-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled (尽管在完全不同的上下文中存在问题)。 This answer , however, suggests that CMSPermGenSweepingEnabled is unnecessary on Java 6 and that -XX:+UseConcMarkSweepGC must be used for CMSClassUnloadingEnabled to be effective. 但是, 这个答案表明在Java 6上不需要CMSPermGenSweepingEnabled ,而且-XX:+UseConcMarkSweepGC必须使用CMSClassUnloadingEnabled才能使CMSClassUnloadingEnabled生效。

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. 至少-XX:+CMSClassUnloadingEnabled可以做到这一点,假设底层问题是由Tomcat实例的PermGen空间中不必要地维护的类引起的。

maybe this question can help you: 也许这个问题可以帮助你:

How to give Jenkins more heap space when it´s started as a service under Windows? 如何在Windows下作为服务启动时为Jenkins提供更多堆空间?

There are some very good answers there. 那里有一些非常好的答案。

I found bumping the JRE to Java 8 helped. 我发现将JRE推向Java 8有所帮助。 By default Jenkins uses the JRE under the home folder, invoked by the jenkins.xml task 默认情况下,Jenkins使用jenkins.xml任务调用的主文件夹下的JRE

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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