https://issues.apache.org/bugzilla/show_bug.cgi?id=51640

Mark Thomas <ma...@apache.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #1 from Mark Thomas <ma...@apache.org> 2011-08-10 13:42:42 UTC ---
clearReferencesJdbc should not (and does not) leave any JDBC drivers loaded.

However, clearReferencesJdbc uses DriverManager to see what JDBC drivers are
currently loaded. Unfortunately, the first ever call to DriverManager has the
side-effect that any JDBC drivers in the current class loader will also be
loaded. clearReferencesJdbc does ensure that any Driver loaded that way is
immediately unloaded but when the Oracle driver is loaded it also creates the
MBean and that triggers the leak.

The automatic creation of the MBean on driver load looks like a bug to me since
there is no way for that MBean to be automatically destroyed when the Driver is
unloaded. To my mind these things should be symmetric. You load the driver, you
unload the driver. The MBean is automatically created, it should be
automatically destroyed. Neither DriverManager nor Oracle's JDBC driver appear
to follow this principle. Sigh.

What I also realised while looking at this is that only the first web
application to use DriverManager will have it's JDBC drivers automatically
loaded (since initialised is a static in DriverManager). That could lead to an
application working or not working depending on application start order.

It looks like the best way to fix both issues is to call
DriverManager.getDrivers() from the JreMemoryLeakPreventionListener. That fixes
the problem described here and ensures that web application behaviour will be
consistent regardless of start order and usage of DriverManager.

Note that even with this fix, if you use that Driver in a web application you
will get a leak caused by the creation of the MBean.

This has been fixed in trunk and 7.0.x and will be included in 7.0.21 onwards.

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to