Reputation: 15
We have a PermGen Out of memory exception in our Java EE web application:
java.lang.OutOfMemoryError: PermGen space
We have read so many posts about how to solve it and almost all of them say that we have to increase PermSize (default and maximum). But we are not able to change them. We have tried to modify setenv.sh, catalina.sh and startup.sh adding this code:
export JAVA_OPTS="-XX:PermSize=M -XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"
And we also try to do it using the terminal:
export JVM_ARGS="-XX:PermSize=256m-XX:MaxPermSize=1024m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"
But when we check it using "jstat -gcpermcapacity " nothing changes; the memory is always the same. Our enviroment is Centos 6, Apache 2.2, Tomcat 5.5, Java 6 and we have done our app deploy installing servlets by WHM in our account.
Upvotes: 0
Views: 3946
Reputation: 15
We have solved the problem! Our application runs on WHM, and the script that execute the restart of Tomcat does not use the startup.sh file. In our case, the reset is performed by "starttomcat", a file found in /usr/bin. We have modified the file, leaving the variable my @ cmd as follows:
my @cmd = (
"./jsvc",
"-user",
"$user",
"-XX:PermSize=64M",
"-XX:MaxPermSize=512m",
"-cp",
"$jars",
"-Djava.endorsed.dirs=../common/endorsed",
"-outfile",
"${logdir}/catalina.out",
"-errfile",
"${logdir}/catalina.err",
"-verbose",
@options,
"org.apache.catalina.startup.Bootstrap",
#"-security",
"start",
);
It runs!
Upvotes: 0
Reputation: 5130
Try changing it in your tomcat.conf. Actually, check with ps ax | grep java to see what command line has been run to generate your parameters. Mine produces:
26552 pts/1 Sl 0:36 /usr/lib/jvm/jre/bin/java -Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=n -Xmx1024m -XX:MaxPermSize=128m -classpath :/usr/share/tomcat6/bin/bootstrap.jar:/usr/share/tomcat6/bin/tomcat-juli.jar:/usr/share/java/commons-daemon.jar -Dcatalina.base=/usr/share/tomcat6 -Dcatalina.home=/usr/share/tomcat6 -Djava.endorsed.dirs= -Djava.io.tmpdir=/var/tmp/tomcat6 -Djava.util.logging.config.file=/usr/share/tomcat6/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager org.apache.catalina.startup.Bootstrap start
this is on tomcat6, java6, centos 5.5
Upvotes: 2