BACKGROUND: I have a web Project which uses JSP. The IDE is Eclipse. The configuration of tomcat is: Automatically publish when resources change and publish
setting like this:
-Xms128m -Xmx1024m -XX:PermSize=64m -XX:MaxPermSize=256m
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.
You may set environment variable named : "JAVA_OPTS
" and set value of it as follows -Xms256m -Xmx1024m -XX:PermSize=256m -XX:MaxPermSize=512m
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
FOR ECLIPSE
FOR NETBEANS
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
Just to add for Windows, if someone is still stuck:--
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
Restart Tomcat and its done.
You can find nice explanation here