Dealing with Java's PermGen space failure

The "OutOfMemoryError: PermGen space" message is normally encountered during development activities where a JVM is asked to load and unload builds frequently and in a short time. This is pretty common when you have tools like Eclipse, and you're performing several deployments on Tomcat, while it is still running, which shouldn't be a problem when you are in your development box.  The real problem appears when these errors show up in staging and/or production environments, where downtimes are extremely harmful.

This message relates to an incomplete garbage collection process where resources are not properly released when unloaded or restarted. A lot of popular and well known tools face this problem from time to time, like Hibernate, Tomcat and even Sun's JVM.  Also, this problem appears frequently when you're using Hudson as your CI server


You could change some pieces of your technology stack, and perform some refactoring on your code, but you'll probably end up in a situation where you can't really optimize any more, without rewriting the code on the underlying libraries.  In this case, the easiest and quickest way to resolve this issue is to switch from Sun's JVM implementation to Oracle's (former BEA's) freely available JRockit implementation.  JRockit handles PermGen completely different as Sun does, so the PermGen error messages should go away.

In addition to this, due to some other performance differences, JRockit is not recommended for development environments, but it's the best choice for production/staging environments

 

.

Hope it helps!

Comments (0)