Tomcat:传递 -XX:MaxPermSize 没有可见效果
我正在尝试将我的应用程序部署到 Tomcat,但未能成功。我不断收到 OutofMemoryError permgen space。 我尝试过各种命令行开关(在stackoverflow上搜索了与此相关的不同问题),例如 -XX:MaxPermSize、-XX:PermSize、-XX:+CMSClassUnloadingEnabled、-XX:+CMSPermGenSweepingEnabled
我将 permgen 大小指定为 64、128、256, 512,但都不起作用。
有趣的是,当我收到错误时,我在任务管理器中看到 java 进程仅占用大约 300mb 内存。我将 -Xms 设置为 1024m,但内存消耗仍然在 300mb 左右。
正在寻求有关可能原因的意见?
我的系统详细信息: 戴尔 Latitude 5420 赢XP 32位 4 GB 内存
I am trying to deploy my application to Tomcat, but haven't been able to do so. I constantly keep getting OutofMemoryError permgen space.
I have tried various command line switches(searched different questions regarding this on stackoverflow) like -XX:MaxPermSize, -XX:PermSize, -XX:+CMSClassUnloadingEnabled, -XX:+CMSPermGenSweepingEnabled
I gave the permgen size as 64, 128, 256, 512, but none of them works.
Interestingly, when I receive the error, I see in task manager the java process is only taking up about 300mb memory. I am passing -Xms as 1024m, but still the memory consumption is around 300mb.
Looking for opinions on what could be the reason?
My system details:
Dell Latitude 5420
Win XP 32 Bit
4 GB RAM
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当您说“不断”时,您的意思是在连续完成多次重新部署之后吗?如果是,这是 Tomcat 的一个众所周知的缺陷,您对此无能为力。增加永久代空间只会推迟不可避免的事情。
原因是反射动态创建的类最终位于永久代空间中,永远不会被回收。因此,名称为“perm gen”——这是垃圾收集器不会触及的永久代。
守恒定律告诉你,如果你的容量是有限的,而你只增加而不删除,你最终会耗尽容量。这就是你这里发生的事情。
When you say "constantly", do you mean after you've done several redeploys in a row? If yes, this is a well-known flaw with Tomcat that you can't do anything about. Increasing perm gen space will only delay the inevitable.
The reason is that reflection creates classes dynamically that end up in the perm gen space, never to be reclaimed. Hence the name 'perm gen' - this is the permanent generation that the garbage collector doesn't touch.
Conservation laws tell you that if you have a finite capacity, and you only add to it without removing, you'll eventually run out of capacity. That's what is happening to you here.
除了 Udo Fholl 的回答之外:Maximum Heap 的正确参数是
-Xmx1024M
In addition to Udo Fholl's answer: The right parameter for Maximum Heap ist
-Xmx1024M
Tomcat 需要环境变量 JAVA_OPTS。例如:
Tomcat needs the environment-variable JAVA_OPTS. For example:
-Xms=1024
表示起始内存为 1024,但是当不需要时,它会缩小它。-Xms=1024
means that the starting memory is 1024, but then, when it is not needed it shrink it.