I have a website deployed to a tomcat server which has been very rapidly using up its available heap space (Old Gen) then crashing. When I took a heap dump i found that most (if not all) of the space is being taken up by lots of org.hibernate.impl.SessionFactoryImpl instances (802 to be precise with a keep alive size of 541mb) (referenced from org.apache.catalina.loader.WebappClassLoader -> java.util.concurrent.ConcurrentHashMap$HashEntry)
About the server The server is tomcat 6 proxied by apache2 using proxypass.
About the software I am using opencms to content manage the webapp and as such all the code is called through its template classes Hibernate is accessed using springs HibernateTemplate. The data source is held in tomcat and is accessed through org.springframework.jndi.JndiObjectFactoryBean and injected into my datasource (org.apache.commons.dbcp.BasicDataSource), the session factory is configured as below.
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list><value>com.someobjects.SomeObject</value>
</list>
</property>
Does any one know why org.hibernate.impl.SessionFactoryImpl is not being garbage collected?
I can provide any further information required... I really am at a loss with this one. Any help is much appreciated.