jenkins java.lang.outofmemoryerror permgen space issues

Solution 1

In Windows: Go to environment variable and add following variables

export JAVA_OPTS="-XX:MaxPermSize=512m -Xms512m -Xmx1024m"
export GRADLE_OPTS="-XX:MaxPermSize=512m"
export SONAR_RUNNER_OPTS="-Xmx512m -XX:MaxPermSize=512m"

In Linux:
In my ~/.bash_profile file, I have set the following 3 variables. Note there are other variables in this file as well i.e. JAVA_HOME, ANT_HOME, SONAR_HOME, SONAR_RUNNER_HOME, etc:

export JAVA_OPTS="-XX:MaxPermSize=512m -Xms512m -Xmx1024m"
export GRADLE_OPTS="-XX:MaxPermSize=512m"
export SONAR_RUNNER_OPTS="-Xmx512m -XX:MaxPermSize=512m"

Solution 2
You can set the -Xmx or -XX:MaxPermSize in your Jenkins global configuration. To do this, navigate to Jenkins global configuration page (Manage Jenkins -> Configure System)

Name - JAVA_OPTS
Value - "-XX:MaxPermSize=512m -Xms512m -Xmx1024m"

You can set similarlity for maven, gradle, sonar as well under "Maven Project Configuration" or grade project configuration.

Name - GRADLE_OPTS
Value - "-XX:MaxPermSize=512m"

Solution 3

They way you can modify this value depends on the distribution and depending on the slave type

Master

In RedHat, for example, you can do it under /etc/sysconfig/jenkins using the variable JENKINS_JAVA_OPTIONS... i.e JENKINS_JAVA_OPTIONS="-XX:MaxPermSize=512m".
In Ubuntu, the Jenkins configuration file is under /etc/default/jenkins and the variable to configure is JAVA_ARGS ... i.e JAVA_ARGS="-XX:MaxPermSize=512m".

Slave

Sometimes slave machines will require permgen to be increased. Depending on the type of slave that is configured will require a different method for setting any java argument.

With SSH Slaves, the java process is started using an SSH command, so the "-XX:MaxPermSize=512m" can be set in the JVM Options in the Node configuration page.
With JNLP Slaves launching as a service on linux, you can add the VM arguments to the startup scripts (usually in /etc/sysconfig/jenkins or /etc/default/jenkins as part of the JAVA_ARGS variable)
With JNLP Slaves launching as a service on Windows requires modifications to be made on the jenkins.xml file which is located on slave machine in the JENKINS_HOME directory.

Reference
http://stackoverflow.com/questions/18000841/jenkins-java-lang-outofmemoryerror-permgen-space
https://wiki.jenkins-ci.org/display/JENKINS/Builds+failing+with+OutOfMemoryErrors
https://cloudbees.zendesk.com/hc/en-us/articles/204264000-Why-do-I-receive-java-lang-OutOfMemoryError-PermGen-space
http://stackoverflow.com/questions/14762162/how-do-i-give-jenkins-more-heap-space-when-its-running-as-a-daemon-on-ubuntu
http://stackoverflow.com/questions/18000841/jenkins-java-lang-outofmemoryerror-permgen-space
http://javarevisited.blogspot.nl/2011/09/javalangoutofmemoryerror-permgen-space.html
https://plumbr.eu/outofmemoryerror/permgen-space

Rate this item
(1 Vote)
Rajesh Kumar

.

Total, Over 12 years of extensive experience in the Software Configuration Management domain having depth knowledge of DevOps, Continuous Integration and Delivery, Configuration Management, Build and Installer, Release Management and Application Management.

What corporate management say about us?

Rajesh is very knowledgeable instructor he has a good exposure on real time issue and case studies he is experienced in large environment issue and challenges. I really liked how Rajesh used a lot of examples so that concepts were more easily understood, I like the examples that Rajesh give to help us remember things…they are usually real scenario, real life problems that we encounter frequently. <br /> He is well organised in terms of study materiel that you can refer anytime after you complete your course. His blogs are crisp and has to the point key content that he discussed during session to remember if you refer them remotely.

Gaurav Vishnoi
I am having 11+ years of experience in java, due to increasing complexity of system and environment I opted for this tanning and find it very useful., Noida
Sep 02, 2016

Authors

Login