Bug 49230

Summary: sun.net.www.http.KeepAliveCache preventing classloader from being garbage collected
Product: Tomcat 6 Reporter: Rob Kooper <kooper>
Component: CatalinaAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: unspecified   
Target Milestone: default   
Hardware: PC   
OS: All   
Attachments: patch to jreMemoryLeakPreventionListener to load sun.net.www.http.KeepAliveCache using system classloader

Description Rob Kooper 2010-04-29 12:17:59 UTC
Created attachment 25377 [details]
patch to jreMemoryLeakPreventionListener to load sun.net.www.http.KeepAliveCache using system classloader

When a servlet creates a URLConnection, internally this is done using sun.net.www.http.HttpClient. To have the ability to keep connections alive and close them after a certain time they are placed inside a cache. A static reference is kept to this cache (sun.net.www.http.KeepAliveCache).

It seems this cache is never released and the classloader stays in memory.

I have a patch to jreMemoryLeakPreventionListener.java that will make sure the KeepAliveCache is loaded by the system classloader and not the webAppClassLoader.
Comment 1 Mark Thomas 2010-06-22 05:25:02 UTC
Thanks for the patch. It has been applied to 7.0.x and will be included in 7.0.1 onwards.

I have also proposed the patch for back-port to  to 6.0.x
Comment 2 Sylvain Laurent 2010-06-22 15:36:52 UTC
IMHO, logging an error if the class is not found might induce some users of non-Sun JVMs in error...

an INFO level is probably enough, with a message explaining that it might be normal with some JVMs.
Comment 3 Mark Thomas 2010-06-23 03:44:14 UTC
I've aligned the patch with how we handle other Sun specific issues for non-Sun JVMs.
Comment 4 Mark Thomas 2010-06-26 04:29:39 UTC
This has been fixed in 6.0.x and will be included in 6.0.28 onwards.