0

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.

4

2 回答 2

2

尝试在您的 tomcat.conf 中更改它。实际上,请检查 ps ax | grep java 查看运行了哪些命令行来生成参数。我的生产:

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

这是在 tomcat6、java6、centos 5.5 上

于 2012-05-22T11:42:31.813 回答
0

我们已经解决了这个问题!我们的应用程序运行在WHM上,执行 Tomcat 重启的脚本没有使用startup.sh文件。在我们的例子中,重置是由/usr/bin中的文件“starttomcat”执行的。我们修改了文件,将变量my@cmd保留如下:

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",
);

它运行!

于 2012-05-23T14:51:17.600 回答