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:

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

Also, the following articles can be helpful:

(113 vote(s))
Not helpful

Comments (0)