jBoss 4.0.2 多次部署相同的 WAR 会导致 jBoss 由于 PermGem/Out-of-Memory 错误而崩溃
我开发 Web 应用程序并使用 jBoss 4.0.2,当我使用 eclipse 多次重新部署 WAR 时,jBoss 将崩溃,因为它耗尽了内存。当我必须将新版本安装到生产环境时,它将消耗生产服务器内存,这意味着我必须停止 jBoss 以防止从客户服务器重新部署内存。有解决这个问题的方法吗?
I develop web applications and I use jBoss 4.0.2 and when I have redeployed my WAR several times with eclipse, jBoss will crash because it runs out of memory. And when I have to install new version to production enviroment, it will consume production servers memory, so that means I have to stop jBoss to prevent redeploying eat memory from customers server. Is there any work around for this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
基本上,没有。由于 JBoss 类加载器的工作方式,每次部署都会使用一块 PermGen,即使应用程序取消部署,该块也不会被释放。
您可以通过将 PermGen 内存池大小增加到数百兆(甚至千兆)来缓解症状,这使得问题更容易解决。我还发现,减少代码中静态字段(尤其是引用大对象的静态字段)的使用可以减少对 PermGen 的影响。
理想情况下,我不会在生产中使用热部署,而是关闭服务器,替换 WAR/EAR,然后重新启动它。
Basically, no. Because of the way the JBoss classloaders work, each deployment will use up a chunk of PermGen that will not be released even if the application is undeployed.
You can mitigate the symptoms by ramping up the PermGen memory pool size to several hundred megs (or even gigs), which makes the problem easier to live with. I've also found that reducing the usage of static fields in your code (especially static fields that refer to large objects) reduces the impact on PermGen.
Ideally, I would not use hot deployment in production, but rather shut the server down, replace the WAR/EAR, then restart it.
我不确定它是否有关联,但我怀疑它是关联的 - JBoss 在实现应用程序分离方面不符合 J2EE,因为它是开箱即用的。
随之而来的是,有一个类加载器将所有类放入其中,因此不可能卸载类,因此您将遇到此问题。您可以将 jboss 配置为在这方面更加符合 J2EE。
您是否遇到了“内存不足 Permgen”,或者您是否经常出现内存不足?
我还通过将 JProfiler 连接到它并用它检查内存使用情况取得了进展。
我最终只是简单地重新启动 Jboss - 并没有占用太多时间。
I'm not sure it's linked, but I suspect it is - JBoss is not J2EE compliant as far as implementing application separation as it comes out of the box.
As it comes, there is one classloader into which all classes are put and thus it is not possible to unload classes and therefore you are going to have this problem. You can configure jboss to be more J2EE compliant in this respect.
Are you getting the "out of memory Permgen" or are you getting regular out of memory?
I also made progress by connecting JProfiler up to it and checking memory usage with this.
I ended up simply restarting Jboss all the time - didn't take up too much time.
试试这个(适用于 Sun 的 Java):
-XX:+UseConcMarkSweepGC
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloading启用
-XX:MaxPermSize=128m
CMS实际上可以GC永久生成堆(你的类所在的堆)。设置 MaxPermSize 是不必要的,但对于应用程序服务器来说默认值较低。
Try this (which applies to Sun's Java):
-XX:+UseConcMarkSweepGC
-XX:+CMSPermGenSweepingEnabled
-XX:+CMSClassUnloadingEnabled
-XX:MaxPermSize=128m
CMS can actually GC the permanent generation heap (the heap where your classes are). Setting MaxPermSize is unnecessary, but the default is low for an application server.