PermGen Space issue in Jenkins

2019-07-13 17:48发布

问题:

I am building a maven project, since last 1.5 yrs build was working fine but now I am getting the PermGen space error.

[ERROR] Internal error: java.lang.RuntimeException: org.jfrog.build.extractor.maven.BuildInfoRecorder.sessionEnded() listener has failed: java.io.IOException: Remote call on channel failed: PermGen space -> [Help 1]
[ERROR] org.jfrog.build.extractor.maven.BuildInfoRecorder.sessionEnded() listener has failed:
java.lang.OutOfMemoryError: PermGen space

I have tried below options in order to resolve it:-

1) Under Manage Jenkins, then Configure System. In the Global properties section, added Environment Variables called MAVEN_OPTS with the value set as -Xmx200m -XX:MaxPermSize=512m

2) Under job configuration, then Build, in the MAVEN_OPTS, added below properties:-

-DXms512m
-DXmx1024m
-DXX:PermSize=512m
-DXX:MaxPermSize=1024m
-DXX:+CMSClassUnloadingEnabled
-DXX:+UseConcMarkSweepGC

Still the error is occurring.

Note:- Error is not permanent, it goes away after few builds but again start appearing and then again goes away after several retries.

Thanks.

回答1:

Maybe I'm wrong, but it seems that your memory error happens when Jenkins try to send the build information to Artifactory (with a post step action).

Did you upgrade the Jenkins Artifactory plugin recently?

Can you try do disable the "Capture and publish build info" option?

And last option, can you try update the JENKINS_JAVA_OPTIONS (in the jenkins service config file) to increase the MaxPermSize?

## Type: string
## Default:     "-Djava.awt.headless=true"
## ServiceRestart: jenkins
#
# Options to pass to java when running Jenkins.
#
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xms2G -Xmx4G -XX:MaxPermSize=256m"


回答2:

As Maven project deploys artifacts not during build step on a node, but on the master, I suspect Permgen problem could by resolved by either upgrading Jenkins core, plugins or by increasing Permgen max size in Jenkins startup options.

ps. Java 8 obsoletes Permgen.



回答3:

maybe I am blind and you have written it somewhere but when I have faced a similar issue, then I have upgraded the JRE version for Jenkins itself from 7 to 8. The problem started, when I have used Jenkins 2.X and Java 7.

Best regards,

Max



回答4:

on centos6 install jenkins by rpm or yum

vim /etc/sysconfig/jenkins
JENKINS_JAVA_OPTIONS="-Djava.awt.headless=true -Xmx1024m -XX:MaxPermSize=512m"