Knowledgebase: Java/JSP Hosting Plans
Facing an exception - java.lang.OutOfMemoryError: PermGen space.
Posted by - NA - on 01 April 2009 06:28 AM

The "OutOfMemoryError: PermGen space" message is normally encountered during development activites where a long-running JVM is asked to load/unload builds. However it can also be encountered in a recently spawned JVM under the "right" set of conditions. The message is a symptom of an incomplete garbage collection sweep where resources are not properly released upon unload/restart. By default PermGen size is set to 192M and unfortunately cannot be increased on a shared server. This error means that your application doesn't have enough memory for binary code and methods of your classes. It's usually caused by two reasons:

1. Frequent redeployments of the application - Tomcat doesn't free PermGen space on redeployments. So, if the application isn't under development then this error wouldn't normally appear. In brief, to solve the problem you should restart Tomcat each time you deploy/undeploy your application. Please note, that would be better to test your app from your side, not on shared production server.

2. Classloader leaks. Here is a good technical explanation on these leaks and steps needed to find out and fix them:

http://blogs.sun.com/fkieviet/entry/classloader_leaks_the_dreaded_java

More info about how to prevent this exception in future you can find at Java official documentation regarding garbage collection:

http://java.sun.com/javase/technologies/hotspot/gc/index.jsp

Also, the following articles can be helpful:

http://www.alessandroribeiro.com/?q=en/node/33
http://www.alessandroribeiro.com/?q=en/node/39
http://www.alessandroribeiro.com/?q=en/node/41
http://jroller.com/agileanswers/date/20060623

(113 vote(s))
Helpful
Not helpful

Comments (0)