gpt4 book ai didi

memory - 电梯和码头的 PermGen 问题

转载 作者:IT王子 更新时间:2023-10-28 23:28:38 25 4
gpt4 key购买 nike

我正在标准 Lift 平台(maven 和 jetty)上进行开发。我反复(每两天一次)得到这个:

Exception in thread "7048009@qtp-3179125-12" java.lang.OutOfMemoryError: PermGen space
2009-09-15 19:41:38.629::WARN: handle failed
java.lang.OutOfMemoryError: PermGen space

这是在我的开发环境中。这不是问题,因为我可以继续重新启动服务器。在部署中我没有这些问题,所以这不是一个真正的问题。我只是好奇。

我对 JVM 了解不多。我认为我认为永久代内存用于类和实习字符串之类的东西是正确的?我记得有点和.NET内存模型混淆了……

发生这种情况的任何原因?默认值是不是非常低?它是否与 Scala 必须为 Function 对象和类似的 FP 事物创建的所有辅助对象有关?每次我用新编写的代码(每隔几分钟)重新启动 Jetty 时,我想它会重新加载类等。但即便如此,它不可能有那么多可以吗?而且JVM不应该能够处理大量的类吗?

干杯

最佳答案

来自 this post :

This exception occurred for one simple reason :
the permgenspace is where class properties, such as methods, fields, annotations, and also static variables, etc. are stored in the Java VM, but this space has the particularity to not being cleaned by the garbage collector. So if your webapp uses or creates a lot of classes (I’m thinking dynamic generations of classes), chances are you met this problem. Here are some solutions that helped me get rid of this exception :

  • -XX:+CMSClassUnloadingEnabled : 此设置启用 permgenspace 中的垃圾回收
  • -XX:+CMSPermGenSweepingEnabled : 允许垃圾收集器从内存中删除偶数类
  • -XX:PermSize=64M -XX:MaxPermSize=128M :提高分配给 permgenspace 的内存量

这可能会有所帮助。

2012 年 7 月编辑(将近 3 年后):

Ondra Žižka评论(我已经更新了上面的答案):

JVM 1.6.0_27 says: Please use:

  • CMSClassUnloadingEnabled(使用CMS GC时是否开启类卸载)
  • 将来代替 CMSPermGenSweepingEnabled

查看完整的 Hotspot JVM Options - The complete reference为先生。

关于memory - 电梯和码头的 PermGen 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1451648/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com