How to Resolve jenkins java.lang.outofmemoryerror permgen space issues?

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

Tagged : / / / / / / / / /

Jenkins Troubleshooting Guide

jenkins-troubleshooting

Jenkins Troubleshooting

Jenkins is one of the important CI tools which many organization used as part of their Build and DevOps infrasture. I am going to consolidate all the troubshooting techniques which can be used in order to find any issues related in jenkins.

Step 1. Take a look at Log generated by the jenkins and plugins via http://jenkins-master/log

Note: Here you can also create your own logger and and set your custom log levels such as (severe, warning, info, config, file, finer, finest, all)

Step 2. Also, you can look at /var/log/jenkins/jenkins.log via doing “tail -f /var/log/jenkins/jenkins.log” and check carefully whats breaking it.

Log file in windows – jenkins.err.log & jenkins.out.log

Slave log file in windows – logs\slaves

Step 3. Check the system log file

Step 4. Few Jenkins plugins which can you help you
https://wiki.jenkins-ci.org/display/JENKINS/Monitoring

Step 4. Make sure your Jenkins & installed plugins version is installed with most uptodate stable release.

Some Common issues:
Issues 1. If Jenkins hangs, follow https://wiki.jenkins-ci.org/display/JENKINS/Jenkins+is+hanging

Issues 2 Site is down with no 404 messages
Cause- Jenkins had an Out of Memory (OOM) error causing the server to kill the jenkins instance
Solution: Restart server; Review heap logs to identify root cause of error

Issues 3 Site is up however no jobs are displayed
Cause 1: AWS Server rebooted but data volume did not mount properly
Solution: mount <device> <path> on the instance

Issues 4 – java.lang.outofmemoryerror permgen space issues

Solution – http://www.scmgalaxy.com/scm/build-workflow-management/jenkins/jenkins-java-lang-outofmemoryerror-permgen-space-issues.html

Tagged : / / / / / / / / /