java MaxPermSize 忽略了 Tomcat 7

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13875256/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 14:17:01  来源:igfitidea点击:

MaxPermSize ignored Tomcat 7

javatomcatpermgen

提问by harmjanr

I'm trying to run several tools on a Windows Tomcat server . The server starts fine, and I can also see the manager page of Tomcat. But when I open a tool, an "OutOfMemoryError: PermGen space" occurs. I tried a lot with setting the MaxPermSize in my catalina.bat, this is my CATALINA_OPTS:

我正在尝试在 Windows Tomcat 服务器上运行多个工具。服务器启动正常,我也可以看到Tomcat的manager页面。但是当我打开一个工具时,会出现“OutOfMemoryError: PermGen space”。我尝试了很多在 catalina.bat 中设置 MaxPermSize,这是我的 CATALINA_OPTS:

set CATALINA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms64m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled"

When I run JVisualVM next to my Tomcat server, I can see that the arguments are picked up well: overview

当我在 Tomcat 服务器旁边运行 JVisualVM 时,我可以看到参数被很好地拾取: 概述

But when I go to the monitor tab and check the PermGen, the max is 67mb instead of the 512 that I set my CATALINA_OPTS. So the arguments are set, but Tomcat ignores them.. permgen

但是当我转到监视器选项卡并检查 PermGen 时,最大值是 67mb 而不是我设置的 CATALINA_OPTS 的 512。因此设置了参数,但 Tomcat 忽略了它们。 永久

I tried fixing this problem for a couple of hours already, but without success..

我已经尝试解决这个问题几个小时了,但没有成功。

Anyone?

任何人?

回答by DelGurth

Remove the "" in the set and you are fine... Don't know why, yet. But that's the answer

删除集合中的“”,你就没事了......还不知道为什么。但这就是答案

set CATALINA_OPTS=-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms64m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

set CATALINA_OPTS=-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms64m -Xmx512m -XX:PermSize=128m -XX:MaxPermSize=512m -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

-- edit

- 编辑

Btw, I think you want the UseConcMarkSweepGC as well, otherwise the other 2 CMS parameters won't do a thing (and one of the 2 is only needed, depening on the version of the JVM)

顺便说一句,我认为您也需要 UseConcMarkSweepGC,否则其他 2 个 CMS 参数将无济于事(仅需要 2 个中的一个,取决于 JVM 的版本)

See What does JVM flag CMSClassUnloadingEnabled actually do?

请参阅 JVM 标志 CMSClassUnloadingEnabled 实际上做了什么?

-- edit 2

-- 编辑 2

This question was also asked for tomcat6 here: https://serverfault.com/questions/64894/setting-catalina-opts-for-tomcat6-on-windows-doesnt-work

这个问题也被问到这里的 tomcat6:https://serverfault.com/questions/64894/setting-catalina-opts-for-tomcat6-on-windows-doesnt-work

Too bad the blogger doesn't explain why you don't need to use quotes in windows.

太糟糕了,博主没有解释为什么你不需要在 Windows 中使用引号。

http://javahowto.blogspot.nl/2006/06/6-common-errors-in-setting-java-heap.html

http://javahowto.blogspot.nl/2006/06/6-common-errors-in-setting-java-heap.html

But I think it's because with the quotes it's seen as one big argument. The only thing that I don't understand is why the jvisualvm pretends you set it correctly. But I guess the display of the arguments doesn't actually look at how it's set in the JVM, but only formats the arguments nicely.

但我认为这是因为引用被视为一个大论点。我唯一不明白的是为什么 jvisualvm 假装你设置正确。但我想参数的显示实际上并不看它在 JVM 中是如何设置的,而只是很好地格式化参数。