Search code examples
javahibernatejakarta-eetomcatjvisualvm

Memory leak in web-app, tomcat+hibernate+Guice


After several redeploys app crashes with PermGen error. I know abou workarounds with increasing permgen size. But I try to reveal cause of leak. After redeploy I'v made heap dump with jvisualvm and searching for instances of WebAppClassLoader. As expected there was one not GC-ed. Show nearest GC root points to platformMBeanServer (MangementFactory type). So the question is what can i do with it?

enter image description here

And some additional info. My jdbc driver jar locates in lib directory of tomcat and .dll file in bin directory. When I comment hibernate sessionFactory creation - problem disappear. Session factory created in init method of servlet filter, and closed in destroy method. Hibernate uses c3p0 connection pool.


Solution

  • I'v found solution. It turns up that connection pool c3p0 0.9.2.1 has memory leak. And hibernate 4.3.1-Final uses that version of c3p0. Switching to hibernate 4.1.12 and c3p0 0.9.1 solve my problem.