0

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.

Kolchuga
  • 716
  • 6
  • 17
  • You need to follow GC roots. Did they point you to that particular object, or are you just guessing? Try reading http://people.apache.org/~markt/presentations/2010-11-04-Memory-Leaks-60mins.pdf to find out how to locate memory leaks such as these. – Christopher Schultz Mar 04 '14 at 15:02

2 Answers2

0

You can try adding these Java options:

-XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled

This enables garbage collection in PermGen space (off by default) and allows the GC to unload classes.

Salah
  • 8,567
  • 3
  • 26
  • 43
0

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.

Kolchuga
  • 716
  • 6
  • 17