{"id":95,"date":"2009-03-12T13:44:04","date_gmt":"2009-03-12T20:44:04","guid":{"rendered":"http:\/\/www.zulutown.com\/blog\/?p=95"},"modified":"2009-03-12T13:44:05","modified_gmt":"2009-03-12T20:44:05","slug":"solving-tomcat-outofmemoryerror-heap-space-and-permgen-space","status":"publish","type":"post","link":"https:\/\/www.zulutown.com\/blog\/2009\/03\/12\/solving-tomcat-outofmemoryerror-heap-space-and-permgen-space\/","title":{"rendered":"Solving Tomcat OutOfMemoryError: Heap space and PermGen space"},"content":{"rendered":"<p>It&#8217;s quite common to run In <em>memory problems<\/em> when running some big Java EE application on a Tomcat server.<br \/>\nSome of the most commmon errors are like the following ones.<\/p>\n<p>This is about a full <em>Heap space<\/em>:<\/p>\n<pre>SEVERE: Servlet.service() for servlet jsp threw exception\r\njava.lang.OutOfMemoryError: Java heap space<\/pre>\n<p>This other is about the <em>PermGen space<\/em> that&#8217;s a memory area, where compiled classes (and <code>JSPs<\/code>) are kept, and this error might happen often if the running web application have many .java and .jsp.<\/p>\n<pre>MemoryError: PermGen space\r\njava.lang.OutOfMemoryError: PermGen space<\/pre>\n<p>To increase the memory available to Tomcat, about <em>heap<\/em> and <em>permgen<\/em> the correct options are the following ones.<\/p>\n<p>This sets the max <em>heap<\/em> available to Tomcat at 1Gb of memory:<\/p>\n<pre>--JvmMx 1024<\/pre>\n<p>This sets the max <em>permgen<\/em> available to Tomcat at 256Mb of memory:<\/p>\n<pre>-XX:MaxPermSize=256m<\/pre>\n<p>To change the Tomcat memory settings (when Tomcat is installed on Windows as <em>system service<\/em>), it&#8217;s required to use the command-line tool <code>tomcat6<\/code>. The next command changes the memory settings for the Tomcat service named <em>Tomcat6<\/em><\/p>\n<pre>tomcat6 \/\/US\/\/Tomcat6 --JvmMx 1024 ++JvmOptions=\"-XX:MaxPermSize=256m\"<\/pre>\n<p>The label <code>\/\/US\/\/Tomcat6<\/code> has the meaning of <em>U<\/em>pdating <em>S<\/em>erver parameters for the service named <em>Tomcat6<\/em>.<br \/>\nObviously this command should be executed from the directory <code>C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\bin<\/code> or from wherever is the <code>bin<\/code> directory of your Tomcat installation. Or to make things simple, that directoy should be added to your <code>PATH<\/code> environment variable.<\/p>\n<p>It&#8217;s even possible to update memory settings from a GUI frontend, or to view what happened after running the command line tool. Running the following command:<\/p>\n<pre>tomcat6w \/\/ES\/\/Tomcat6<\/pre>\n<p>a window will open showing all the parameters about the windows service <em>Tomcat6<\/em>.<\/p>\n<p>It&#8217;s possible to see in this image that, after running the previous command, for setting higher memory limits, in the sections <strong>Maximum memory pool<\/strong> and at the end of the <strong>Java Options<\/strong> the new memory limits are set.<\/p>\n<div id=\"attachment_96\" style=\"width: 426px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-96\" class=\"size-full wp-image-96\" title=\"Tomcat Memory Settings on Windows\" src=\"http:\/\/www.zulutown.com\/blog\/wp-content\/uploads\/2009\/03\/configuration.png\" alt=\"Tomcat Memory Settings on Windows\" width=\"416\" height=\"403\" srcset=\"https:\/\/www.zulutown.com\/blog\/wp-content\/uploads\/2009\/03\/configuration.png 416w, https:\/\/www.zulutown.com\/blog\/wp-content\/uploads\/2009\/03\/configuration-300x290.png 300w\" sizes=\"auto, (max-width: 416px) 100vw, 416px\" \/><p id=\"caption-attachment-96\" class=\"wp-caption-text\">Tomcat Memory Settings on Windows<\/p><\/div>\n","protected":false},"excerpt":{"rendered":"<p>It&#8217;s quite common to run In memory problems when running some big Java EE application on a Tomcat server. Some of the most commmon errors are like the following ones. This is about a full Heap space: SEVERE: Servlet.service() for &hellip; <a href=\"https:\/\/www.zulutown.com\/blog\/2009\/03\/12\/solving-tomcat-outofmemoryerror-heap-space-and-permgen-space\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[62,72,67,69,73,71,68,65,66,64,63,5,70],"class_list":["post-95","post","type-post","status-publish","format-standard","hentry","category-tomcat","tag-heap","tag-java-options","tag-jvmmx","tag-jvmoptions","tag-limit","tag-maximum-memory-pool","tag-maxpermsize","tag-memory","tag-outofmemoryerror","tag-permgen-tomcat","tag-space","tag-tomcat6","tag-tomcat6w"],"_links":{"self":[{"href":"https:\/\/www.zulutown.com\/blog\/wp-json\/wp\/v2\/posts\/95","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.zulutown.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zulutown.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zulutown.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zulutown.com\/blog\/wp-json\/wp\/v2\/comments?post=95"}],"version-history":[{"count":4,"href":"https:\/\/www.zulutown.com\/blog\/wp-json\/wp\/v2\/posts\/95\/revisions"}],"predecessor-version":[{"id":100,"href":"https:\/\/www.zulutown.com\/blog\/wp-json\/wp\/v2\/posts\/95\/revisions\/100"}],"wp:attachment":[{"href":"https:\/\/www.zulutown.com\/blog\/wp-json\/wp\/v2\/media?parent=95"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zulutown.com\/blog\/wp-json\/wp\/v2\/categories?post=95"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zulutown.com\/blog\/wp-json\/wp\/v2\/tags?post=95"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}