Oh this blasted error. How many times I’ve seen it in JBoss console. How many restarts because of it.

This has been a nuisance for quite a while. Basically what happens is that every time you (re)deploy an application to JBoss, the java process takes up a bit more memory, until after enough redeployments it runs out.

This blog gives a very good explanation of what the PermGen memory error is, how to monitor it and how to modify how much is available for your application.

This however did not solve the problem, as increasing the available PermGen space simply delayed the inevitable. The memory used by JBoss only goes up after each redeployment, so the painful end is unavoidable.

After chasing around the truth in various forums and blogs, each one suggesting a different culprit for the problem (Tomcat, cglib library, the combination of the two, Hibernate, and more) a colleague got a chance at a conference to ask some JBoss guys themselves for an answer. And an answer we got indeed: This problem happens with the Sun JVM. Use another one and it will go away.

So I did. I tried JRockit. And it worked. The problem went away. That simple.

So if you have the same problem, give it a try. It worked for me and it made my day.