Permgen errors in Tomcat when using Hibernate.

Tags:

Getting rid of the Tomcat permgen errors.

At least enougth to work with.

If like me, you are using the Tomcat servlet container then you may encounter the nasty permgen error while you are developing. Permgen errors happen because the sun implementation of java has four generations in its memory model. The permenant generation of java objects contains classes that will last for the life time of the JVM and these are stored in the permgen memory space in the JVM. The problem is that when you re-deploy your web application too many time (sometimes as little 3-4 times) the JVM runs out of memory and throws the permgen error as duplicate copies of your application seem to gather in the permgen space and fill it up.

In order to get around this while developing I switched to the JRockit implementation of Java. It is easy to use and is a drop in replacement for the sun implementation. It uses a single memory space to store Java objects and so does not have the problem of permgen memory filling up as quickly. If my understanding is correct, it does fill up but it takes a lot longer and so allows you to spend longer developing you web applications and less time waiting for you PITA Tomcat server to reboot.

The permgen error seems to be thrown due to a combination of Hibernate, Tomcat and the JVM but no-one seems to know where the problem actually lies at the moment. Switching to the JRockit implementation of Java is the best solution I have found so far.

I have now been using the JRockit implementation for over a year and have not had a single problem with it.

Comments:

Post a Comment:

HTML Syntax: Allowed