尽管有 JVM 标志,有什么方法可以防止在 tomcat 上以生产模式重新部署时 Grails permgen 泄漏
这是一个熟悉的老问题,但我真的想一劳永逸地解决它!我设置了以下 JVM 标志:
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=true
但我仍然观察到每个部署周期的 permgen 使用量增加了 50MB。我正在使用 Tomcat 管理器应用程序进行远程部署,并且 Grails 处于生产模式。
如果它太满,则需要 kill -9
!
我可能会尝试使用 JRockit,但现在它也不是一个选择。我真的觉得在生产环境中每隔一段时间就必须弹回整个容器是不可接受的。
It's a familiar old problem but I really want to put it to bed once and for all! I've got the following JVM flags set:
-XX:+CMSClassUnloadingEnabled
-XX:+CMSPermGenSweepingEnabled -Dorg.apache.catalina.loader.WebappClassLoader.ENABLE_CLEAR_REFERENCES=true
but I still observe the permgen usage notch up by a good 50MBs for every deployment cycle. I'm deploying remotely using the Tomcat manager application, and Grails is in production mode.
If it gets too full then a kill -9
is necessary!
I might try using JRockit but nor now it's not an option. I don't really find it acceptable in a production environment to have to bounce the whole container every once in a while.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
根据我的经验,无论您在使用 grails 时使用什么应用程序服务器,Permgen 泄漏都是一个问题(非常个人化且可能很容易争论的轶事,只是为了澄清这一点;))。
如果这是您部署的唯一应用程序,为什么不直接 shutdown.sh ,删除 webapp 文件夹,放入 war ,然后放入startup.sh ?
这就是我们的做法,重新部署只需要大约 7 秒(其中 5 秒是
sleep 5
,以确保 catalina 在恢复之前完全关闭)。编辑:
在我看来,每个应用程序拥有一个 tomcat 实例是非常酷的!
Permgen leakage is an issue no matter what appserver you're on when using grails is my experience (highly personal and probably easily contendable anecdote, just to be clear on that ;) ).
If this is the only app you have deployed, why not just shutdown.sh, delete webapp folder, put in war and then startup.sh ?
It's the way we go and the redeployment only gains about 7 seconds (where 5 of those are a
sleep 5
to ensure catalina is fully shutdown before it goes back up).Edit:
Having one tomcat instance per app is pretty cool anyways in my opinion!
你可能没有意识到这一点,但是只要你反复热部署到Tomcat实例,最终就会发生permgem,因为有一些类永远无法正确卸载(或者由于类的编程方式,或者由于某些限制)对于 Tomcat 而言)无论您使用哪个参数,只要重新启动即可。
You may not be aware of this, but permgem will occur eventually as long as you repeatedly hot deploy to the Tomcat instance, since there are some classes that can never be properly unloaded (either due to the way the classes are programmed, or some limitation on the part of Tomcat) no matter which parameters you use, short of a restart.