| Bug #36565 | Statement cancellation timer can cause permgen memory leak in web applications | ||
|---|---|---|---|
| Submitted: | 7 May 2008 16:15 | Modified: | 11 Nov 3:39 |
| Reporter: | Charles Blaxland | ||
| Status: | Won't fix | ||
| Category: | Connector/J | Severity: | S5 (Performance) |
| Version: | 5.1.6 | OS: | Any |
| Assigned to: | Target Version: | ||
| Triage: | D3 (Medium) | ||
[7 May 2008 16:15]
Charles Blaxland
[9 May 2008 11:56]
Tonci Grgin
Hi Charles and thanks for your report. Looking into code and explanation I would agree with you. But, the issue is that this is not *technically* a bug, it's a problem with Sun's VM and how it manages class instances. I've been informed that it will take some time to come up with a clean fix, but, as you can see, out c/J team is aware of the problem.
[10 May 2008 6:51]
Charles Blaxland
Hi Tonci, thanks for the quick reply. I'm not so sure that it's correct to write this off as a simply a "problem" with your JVM (can you point me to a Sun bug database report describing this "problem"?). It's an annoying "oddity" perhaps, but one that Java developers shouldn't just ignore. I do realise however the complicated nature of this problem, and I understand that it's probably not easy for you guys to fix. Perhaps in the meantime you could supply a public static getter or cleanup method for the timer so at least app developers have the ability to clean up the timer themselves when they want to?
[10 May 2008 21:51]
Mark Matthews
Hi Charles, It's really a design issue with the Sun VM, in that classes need to be loaded in permgen. Other VMs (IBM, JRockit) don't have this issue. You can see similar "leaks" when you use Spring, Hibernate, etc. for the same reason. We'll see what we can do to mitigate this, but it will be a tradeoff, in that it will either require end-users to clear the timers themselves, or we'll end up having per-connection cancellation timers. We'll have to do some benchmarking to see which one has the least impact. -Mark
[11 May 2008 5:03]
Charles Blaxland
Thanks Mark, I agree that Sun's JVM *shouldn't* have this problem... but unfortunately it does. I disagree that you *necessarily* see similar leaks when using Spring, Hibernate and other libraries. Yes, other libraries sometimes do sometimes cause permgen leaks, but I've been able to remove all these sorts of leaks from my app now, and a lot of fixes involved upgrading to a newer library versions where the developers had recognised and fixed the problem. Anyway, I appreciate your response. I'd be happy with a cleanup method that I could call myself. Charles
[5 Aug 17:35]
Jim Kool
This hasn't been touched for such a long time but I'll comment on it anyways. Setup Ubuntu (Linux), Java 1.6.0, Tomcat 6.0.18, Connector/J 5.1.7 in tomcat/lib On undeploy, the Timer's internal thread uses the Web app's classloader as the context classloader rather than the Tomcat's standard classloader. Because of the hard reference to classloader from the timer thread, the classes will remain in perm gen forever. In JRockit, it will still be in memory forever, even if it doesn't use perm gen. This is what I found through jhat.
