what to do with tomcat PermGen space

对着背影说爱祢 提交于 2019-11-28 04:09:53
Scott Linford

Tomcat does need a lot of permgen. 512m is not an unreasonable max. However it only delays the hot-deploy leak. Permgen will grow ~25mb per hotdeploy, which, in Eclipse, might be every time you save a Java file. 512m disappears fast if you have a Ctrl+S twitch like me.

The solution: allow Java to kick class definitions out of memory, i.e., garbage collect byte code. Add these along with your boosted permgen size:

-XX:+CMSClassUnloadingEnabled -XX:+UseConcMarkSweepGC
Sourav Bairagi

You may set environment variable named : "JAVA_OPTS" and set value of it as follows -Xms256m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m

FOR ECLIPSE

  1. Go to server properties
  2. Go to platform
  3. Now in VM argument write this -Xms256m -Xmx256m -XX:PermSize=256m -XX:MaxPermSize=512m

FOR NETBEANS

  1. Go to Netbeans folder/etc/
  2. open netbeans.config in any editor
  3. edit this line as

netbeans_default_options="-J-client -J-Xss256m -J-Xms256m -J-XX:PermSize=256m -XX:MaxPermSize=512m -J-Dapple.laf.useScreenMenuBar=true -J-Dapple.awt.graphics.UseQuartz=true -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.dpiaware=true -J-Dsun.zip.disableMemoryMapping=true"

Thats all

setting like this:

-Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m

Just configure it from the apache tomcat interface:

  1. start C:\Program Files\Apache Software Foundation\Tomcat 8.5\bin\Tomcat8w.exe (or you may just search in windows start for "Configure Tomcat");
  2. Go to Java tab;
  3. Set the required space in the input fields:

Nicks

Just to add for Windows, if someone is still stuck:--

  1. Open catalina.bat file (located at Apache tomcat installation folder/bin)
  2. Set JAVA_OPTS as follows in the very start(before actually its first use anywhere in the file):--

    set JAVA_OPTS=-Dfile.encoding=UTF-8 -Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m

  3. Restart Tomcat and its done.

You can find nice explanation here

Purushothaman

Tomcat server runs different JAVA and the eclipse runs in different JAVA.

So adding -XX:MaxPermSize=512m to eclipse.ini will help resolving this issue. Follow the below steps to add this to tomcat server:

  • Double click server in eclipse

  • open launch configuration

  • add "-XX:MaxPermSize=512m" to VM arguments in the Arguments tab.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!