commons-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Daniele (JIRA)" <j...@apache.org>
Subject [jira] Commented: (DBCP-332) Closing BasicDataSource doesn't deregister JDBC driver, causing memory leak
Date Fri, 07 May 2010 12:46:50 GMT

    [ https://issues.apache.org/jira/browse/DBCP-332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12865128#action_12865128
] 

Daniele commented on DBCP-332:
------------------------------

I have Tomcat 6.0.24 and in my catalina.log i see this error:

A web application registered the JBDC driver [com.microsoft.sqlserver.jdbc.SQLServerDriver]
but failed to unregister it when the web application was stopped. To prevent a memory leak,
the JDBC Driver has been forcibly unregistered.
A web application appears to have started a thread named [Thread-4] but has failed to stop
it. This is very likely to create a memory leak.

> Closing BasicDataSource doesn't deregister JDBC driver, causing memory leak
> ---------------------------------------------------------------------------
>
>                 Key: DBCP-332
>                 URL: https://issues.apache.org/jira/browse/DBCP-332
>             Project: Commons Dbcp
>          Issue Type: Bug
>    Affects Versions: 1.3, 1.4
>            Reporter: Grzegorz Borkowski
>             Fix For: 1.3.1, 1.4.1
>
>
> BasicDataSource's method close() doesn't deregister JDBC driver. This causes permgen
memory leaks in web server environments, during context reloads. For example, using Tomcat
6.0.26 with Spring, and BasicDataSource declared in Spring context, there is a message printed
at web application reload:
> SEVERE: A web application registered the JBDC driver [com.mysql.jdbc.Driver] but failed
to unregister it when the web application was stopped. To prevent a memory leak, the JDBC
Driver has been forcibly unregistered.
> I was able to fix it by overriding close method this way:
> {code}
> public class XBasicDataSource extends BasicDataSource {
>     @Override
>     public synchronized void close() throws SQLException {
>         DriverManager.deregisterDriver(DriverManager.getDriver(url));
>         super.close();
>     }
> }
> {code}
> but I think it should be probably the default behavior of BasicDataSource. Or perhaps
there should be some flag/setting on BasicDataSource, named "deregisterDriverAtClose" or so.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message