Preventing Java's java.lang.OutOfMemoryError: PermGen space failure


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...

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

VM arguments

Putting the below startup VM arguments has helped:

-XX:MaxPermSize=256m -XX:+CMSClassUnloadingEnabled

I skipped on the "-XX:+CMSPermGenSweepingEnabled" part as tomcat complained with:

Please use CMSClassUnloadingEnabled in place of CMSPermGenSweepingEnabled in the future