如何确保Tomcat6在Windows上读取CATALINA_OPTS?
我有一个在 Windows2003 机器上运行的 Tomcat6。 我在此服务器上部署了 2 个 Grails 应用程序,很快我就注意到部署后的某个时间一切都崩溃了,并出现了典型的 PermGen 错误。
java.lang.OutOfMemoryError: PermGen space
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
java.lang.ClassLoader.defineClass(ClassLoader.java:616)
org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.de
...
因此,我找到了解决此问题的常见方法:增加堆和永久生成空间:
set CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m"
添加到 C:\apache-tomcat-6.0.26\bin\catalina.bat 中。 不幸的是,这不起作用,但问题是我不确定 Tomcat 是否会接受它。我检查了各种日志,但这些选项从未打印出来。 有没有办法记录它们并确保 Tomcat 已读取它们?
编辑:我尝试使用 tomcat6w.exe 添加以下 JVM 选项:
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:+UseConcMarkSweepGC
并且没有任何改变。正常运行 2-3 分钟后我会获得永久代。 还有其他想法吗?
干杯! 穆隆
I have a Tomcat6 running on a Windows2003 machine.
I deployed 2 Grails apps on this server and I soon noticed that everything was crashing sometime after the deploy with a classic PermGen error.
java.lang.OutOfMemoryError: PermGen space
java.lang.ClassLoader.defineClass1(Native Method)
java.lang.ClassLoader.defineClassCond(ClassLoader.java:632)
java.lang.ClassLoader.defineClass(ClassLoader.java:616)
org.codehaus.groovy.reflection.ClassLoaderForClassArtifacts.de
...
So I found a common fix for this problem: increasing heap and permgen space with:
set CATALINA_OPTS="-Xms1024m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=512m"
Added into C:\apache-tomcat-6.0.26\bin\catalina.bat.
Unfortunately this didn't work, but the problem is that I'm not sure that Tomcat is picking it up. I checked various logs but these options are never printed out.
Is there a way to log them and make sure that Tomcat has read them?
EDIT: I tried to add the following JVM options with tomcat6w.exe:
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled
-XX:+UseConcMarkSweepGC
And nothing changed. I get a permGen after 2-3 minutes of uptime.
Any other idea?
Cheers!
Mulone
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
谢谢大家!
我最终通过添加以下内容解决了该问题:
到 tomcat6w.exe 上的 java 选项。
谢谢!
Thank you all!
I finally solved the issue by adding:
To the java options on tomcat6w.exe.
Thanks!
实际的方法(在 Catalina.bat 中),
将此行添加到这样的位置,以便将此 JAVA_OPTS 传输到文件末尾的任何 _EXECJAVA 命令(if-else 嵌套)。我个人将这一行写为该批次的第一条语句
Actual way to do it (in Catalina.bat),
add this line in such a position so that this JAVA_OPTS is transferred to any of _EXECJAVA command at the end of file (if-else nested). I personally write this line as first statement of this batch
实际上,在启动服务器之前,我将这些设置为我的 JVM 的 JAVA_OPTS
I actually set those as JAVA_OPTS for my JVM before starting the server
查看您在哪里设置它,使用
echo [statements]
进行故障排除,尝试在传递到虚拟机之前对其进行设置,例如:确保您拥有正确的
EXEC_JAVA
不确定您拥有哪个版本的.bat
文件,但可能有几个if
语句。还要确保这些参数对于您的虚拟机来说是有效的。
您可以检查您的java代码中的最大堆大小,使用:
只需打印出来,如果根据您的设置正确,则内存泄漏严重,如果不正确,则
tomcat
不会选择起来吧。Look where you are setting it, use
echo [statements]
to troubleshoot, try setting it right before its passed to the VM, something like:Make sure you have the right
EXEC_JAVA
not sure which version of the.bat
file you have, but probably severalif
statements.Also make sure these are valid arguments for your VM.
You can check your max heap size within your java code, use:
Just print it out, if its correct based on your settings, you have a bad memory leak, if its not, then
tomcat
is not picking it up.