{"id":429,"date":"2015-09-03T06:32:06","date_gmt":"2015-09-03T06:32:06","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2015\/09\/03\/jenkins-java-lang-outofmemoryerror-permgen-space-issues\/"},"modified":"2021-11-19T07:00:16","modified_gmt":"2021-11-19T07:00:16","slug":"jenkins-java-lang-outofmemoryerror-permgen-space-issues","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/jenkins-java-lang-outofmemoryerror-permgen-space-issues\/","title":{"rendered":"How to Resolve jenkins java.lang.outofmemoryerror permgen space issues?"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3367 aligncenter\" src=\"http:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2015\/09\/jenkins-java-lang-outofmemo.png\" alt=\"jenkins-java-lang-outofmemoryerror-permgen-space-issues\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/09\/jenkins-java-lang-outofmemo.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/09\/jenkins-java-lang-outofmemo-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p><strong>Solution 1<\/strong><\/p>\n<p>In Windows: Go to environment variable and add following variables<\/p>\n<p>export JAVA_OPTS=&#8221;-XX:MaxPermSize=512m -Xms512m -Xmx1024m&#8221;<br>\nexport GRADLE_OPTS=&#8221;-XX:MaxPermSize=512m&#8221;<br>\nexport SONAR_RUNNER_OPTS=&#8221;-Xmx512m -XX:MaxPermSize=512m&#8221;<\/p>\n<p>In Linux:<br>\nIn 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:<\/p>\n<p>export JAVA_OPTS=&#8221;-XX:MaxPermSize=512m -Xms512m -Xmx1024m&#8221;<br>\nexport GRADLE_OPTS=&#8221;-XX:MaxPermSize=512m&#8221;<br>\nexport SONAR_RUNNER_OPTS=&#8221;-Xmx512m -XX:MaxPermSize=512m&#8221;<\/p>\n<p><strong>Solution 2<\/strong><br>\nYou can set the -Xmx or -XX:MaxPermSize in your Jenkins global configuration. To do this, navigate to Jenkins global configuration page (Manage Jenkins -&gt; Configure System)<\/p>\n<p>Name &#8211; JAVA_OPTS<br>\nValue &#8211; &#8220;-XX:MaxPermSize=512m -Xms512m -Xmx1024m&#8221;<\/p>\n<p>You can set similarlity for maven, gradle, sonar as well under &#8220;Maven Project Configuration&#8221; or grade project configuration.<\/p>\n<p>Name &#8211; GRADLE_OPTS<br>\nValue &#8211; &#8220;-XX:MaxPermSize=512m&#8221;<\/p>\n<p><strong>Solution 3<\/strong><\/p>\n<p>They way you can modify this value depends on the distribution and depending on the slave type<\/p>\n<p>Master<\/p>\n<p>In RedHat, for example, you can do it under \/etc\/sysconfig\/jenkins using the variable JENKINS_JAVA_OPTIONS&#8230; i.e JENKINS_JAVA_OPTIONS=&#8221;-XX:MaxPermSize=512m&#8221;.<br>\nIn Ubuntu, the Jenkins configuration file is under \/etc\/default\/jenkins and the variable to configure is JAVA_ARGS &#8230; i.e JAVA_ARGS=&#8221;-XX:MaxPermSize=512m&#8221;.<\/p>\n<p>Slave<\/p>\n<p>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.<\/p>\n<p>With SSH Slaves, the java process is started using an SSH command, so the &#8220;-XX:MaxPermSize=512m&#8221; can be set in the JVM Options in the Node configuration page.<br>\nWith 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)<br>\nWith 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.<\/p>\n<p><strong>Reference<\/strong><br>\n<a href=\"http:\/\/stackoverflow.com\/questions\/18000841\/jenkins-java-lang-outofmemoryerror-permgen-space\" target=\"_blank\" rel=\"noopener\">http:\/\/stackoverflow.com\/questions\/18000841\/jenkins-java-lang-outofmemoryerror-permgen-space<\/a><br>\n<a href=\"https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Builds+failing+with+OutOfMemoryErrors\" target=\"_blank\" rel=\"noopener\">https:\/\/wiki.jenkins-ci.org\/display\/JENKINS\/Builds+failing+with+OutOfMemoryErrors<\/a><br>\n<a href=\"https:\/\/cloudbees.zendesk.com\/hc\/en-us\/articles\/204264000-Why-do-I-receive-java-lang-OutOfMemoryError-PermGen-space\" target=\"_blank\" rel=\"noopener\">https:\/\/cloudbees.zendesk.com\/hc\/en-us\/articles\/204264000-Why-do-I-receive-java-lang-OutOfMemoryError-PermGen-space<\/a><br>\n<a href=\"http:\/\/stackoverflow.com\/questions\/14762162\/how-do-i-give-jenkins-more-heap-space-when-its-running-as-a-daemon-on-ubuntu\" target=\"_blank\" rel=\"noopener\">http:\/\/stackoverflow.com\/questions\/14762162\/how-do-i-give-jenkins-more-heap-space-when-its-running-as-a-daemon-on-ubuntu<\/a><br>\n<a href=\"http:\/\/stackoverflow.com\/questions\/18000841\/jenkins-java-lang-outofmemoryerror-permgen-space\" target=\"_blank\" rel=\"noopener\">http:\/\/stackoverflow.com\/questions\/18000841\/jenkins-java-lang-outofmemoryerror-permgen-space<\/a><br>\n<a href=\"http:\/\/javarevisited.blogspot.nl\/2011\/09\/javalangoutofmemoryerror-permgen-space.html\" target=\"_blank\" rel=\"noopener\">http:\/\/javarevisited.blogspot.nl\/2011\/09\/javalangoutofmemoryerror-permgen-space.html<\/a><br>\n<a href=\"https:\/\/plumbr.eu\/outofmemoryerror\/permgen-space\" target=\"_blank\" rel=\"noopener\">https:\/\/plumbr.eu\/outofmemoryerror\/permgen-space<\/a><\/p>\n\n<div class=\"epyt-gallery\" data-currpage=\"1\" id=\"epyt_gallery_11926\"><iframe loading=\"lazy\"  id=\"_ytid_97456\"  width=\"760\" height=\"427\"  data-origwidth=\"760\" data-origheight=\"427\" src=\"https:\/\/www.youtube.com\/embed\/?enablejsapi=1&#038;autoplay=0&#038;cc_load_policy=0&#038;cc_lang_pref=&#038;iv_load_policy=1&#038;loop=0&#038;rel=1&#038;fs=1&#038;playsinline=0&#038;autohide=2&#038;theme=dark&#038;color=red&#038;controls=1&#038;disablekb=0&#038;\" class=\"__youtube_prefs__  no-lazyload\" title=\"YouTube player\"  data-epytgalleryid=\"epyt_gallery_11926\"  allow=\"fullscreen; accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen data-no-lazy=\"1\" data-skipgform_ajax_framebjll=\"\"><\/iframe><div class=\"epyt-gallery-list\"><div>Sorry, there was a YouTube error.<\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>Solution 1 In Windows: Go to environment variable and add following variables export JAVA_OPTS=&#8221;-XX:MaxPermSize=512m -Xms512m -Xmx1024m&#8221; export GRADLE_OPTS=&#8221;-XX:MaxPermSize=512m&#8221; export SONAR_RUNNER_OPTS=&#8221;-Xmx512m -XX:MaxPermSize=512m&#8221; In Linux: In my ~\/.bash_profile file, I have set&#8230; <\/p>\n","protected":false},"author":1,"featured_media":3367,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[42],"tags":[545,1504,145,1505,1506,1503,1507,593,1509,1508],"class_list":["post-429","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-jenkins","tag-how","tag-java-lang-outofmemoryerror-permgen-space","tag-jenkins","tag-jenkins-error","tag-jenkins-issue","tag-jenkins-java-lang-outofmemoryerror-permgen-space","tag-jenkins-space-issue","tag-process","tag-resolve","tag-solution"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=429"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/429\/revisions"}],"predecessor-version":[{"id":25810,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/429\/revisions\/25810"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3367"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}