mysql memory leak_解决Memory Leak问题

异常如下:

2012-2-9 17:43:12 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

严重: The web application [/codeMarket] 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.

2012-2-9 17:43:12 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

严重: The web application [/codeMarket] registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

2012-2-9 17:43:12 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads

严重: The web application [/codeMarket] appears to have started a thread named [Timer-0] but has failed to stop it. This is very likely to create a memory leak.

2012-2-9 17:43:12 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap

严重: The web application [/codeMarket] created a ThreadLocal with key of type [null] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@e1666]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@e0ada6]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.

2012-2-9 17:43:12 org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap

严重: The web application [/codeMarket] created a ThreadLocal with key of type [null] (value [com.opensymphony.xwork2.inject.ContainerImpl$10@a8a314]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@16ab2e8]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.

AbandonedObjectPool is used (org.apache.commons.dbcp.AbandonedObjectPool@11f1f12)

LogAbandoned: false

RemoveAbandoned: true

RemoveAbandonedTimeout: 3600

搜了一堆资料终于搞懂了 赶紧记下来~~

第一个问题:

严重: The web application [/codeMarket] registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

网上资料:

详细如下:

应用程序注册了JDBC驱动,但当程序停止时无法注销这个驱动,tomcat为了防止内存溢出,就给强制注销了

https://issues.apache.org/jira/browse/DBCP-332

解决:

重写了org.apache.commons.dbcp.BasicDataSource 的 close()方法:

packageorg.company.util;importjava.sql.DriverManager;importjava.sql.SQLException;importorg.apache.commons.dbcp.BasicDataSource;public class XBasicDataSource extendsBasicDataSource{

@Overridepublic synchronized void close() throwsSQLException{//System.out.println("......输出数据源Driver的url:"+DriverManager.getDriver(url));

DriverManager.deregisterDriver(DriverManager.getDriver(url));super.close();

}

}

在dbcp数据源中的配置:

class="org.company.util.XBasicDataSource" destroy-method="close">

value="oracle.jdbc.driver.OracleDriver">

value="jdbc:oracle:thin:@XX.XXX.XX.X:1521:ccdb">

问题解决~

再重新加载的时候发现还有:

严重: The web application [/codeMarket] 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.

2012-2-9 17:43:12 org.apache.catalina.loader.WebappClassLoader clearReferencesJdbc

检查了一下jar包 发现多了一个mysql-connector-java-bin.jar 赶紧删之 ok~

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值