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
This is specific to Tomcat. It's pretty a poor hotpublisher/hotdeployer and it suffers from memory leaks. 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. 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. As to how to install Glassfish and integrate it in Eclipse for JSF 2.0 development, check this tutorial.
You have to allocate more space to the PermGenSpace of the tomcat JVM.
This can be done with the JVM argument : -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).
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
If you have more number of projects in your webapps folder this exception will come .Remove some projects this exception will not come.
精彩评论