简体   繁体   English

java.lang.OutOfMemoryError: PermGen 空间

[英]java.lang.OutOfMemoryError: PermGen space

How can I prevent this?我怎样才能防止这种情况?

Exception in thread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" java.lang.OutOfMemoryError: PermGen space
Exception in thread "main" java.lang.OutOfMemoryError: PermGen space
Exception in thread "Thread-2" java.lang.OutOfMemoryError: PermGen space

It's happening for example if I reloading datatable page often.例如,如果我经常重新加载数据表页面,就会发生这种情况。 I understand it that there is something wrong set with garbage collector..我知道垃圾收集器设置有问题..

I'm using Eclipse Java EE IDE, JSF2, richfaces4我正在使用 Eclipse Java EE IDE,JSF2,richfaces4

This is specific to Tomcat.这是特定于 Tomcat 的。 It's pretty a poor hotpublisher/hotdeployer and it suffers from memory leaks.它是一个非常糟糕的热发布器/热部署器,并且存在 memory 泄漏。 I'd suggest to turn off autopublishing by the server configuration screen in Eclipse and just manually restart Tomcat whenever you want to reflect the saved changes.我建议通过 Eclipse 中的服务器配置屏幕关闭自动发布,并在您想要反映保存的更改时手动重新启动 Tomcat。 Restarting shouldn't take much time anyway if you have only one project.如果您只有一个项目,重新启动应该不会花费太多时间。

Glassfish, for example, is much more robust (and faster.) when it comes to hotpublishing.例如,在热发布方面,Glassfish 更加健壮(而且速度更快)。 As to how to install Glassfish and integrate it in Eclipse for JSF 2,0 development, check this tutorial .至于如何安装 Glassfish 并将其集成到 Eclipse 以进行 JSF 2,0 开发,请查看 本教程

You have to allocate more space to the PermGenSpace of the tomcat JVM.您必须为 tomcat JVM 的 PermGenSpace 分配更多空间。

This can be done with the JVM argument: -XX:MaxPermSize=128m这可以通过 JVM 参数来完成: -XX:MaxPermSize=128m

By default, the PermGen space is 64M (and it contains all compiled classes, so if you have a lot of jar (classes) in your classpath, you may indeed fill this space).默认情况下,PermGen 空间是 64M(它包含所有编译的类,所以如果你的类路径中有很多 jar(类),你可能确实会填满这个空间)。

On a side note, you can monitor the size of the PermGen space with JVisualVM and you can even inspect its content with YourKit Java Profiler附带说明一下,您可以使用JVisualVM监控 PermGen 空间的大小,甚至可以使用YourKit Java Profiler检查其内容

If you have more number of projects in your webapps folder this exception will come.Remove some projects this exception will not come.如果您的 webapps 文件夹中有更多项目,则会出现此异常。删除一些不会出现此异常的项目。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM