mysql memory leak_解决memory leak问题
應用程序注冊了JDBC驅動,但當程序停止時無法注銷這個驅動,tomcat為了防止內存溢出,就給強制注銷了
解決:
重寫了org.apache.commons.dbcp.BasicDataSource??的 close()方法:
package org.company.util;
import java.sql.DriverManager;
import java.sql.SQLException;
import org.apache.commons.dbcp.BasicDataSource;
public class XBasicDataSource extends BasicDataSource{
@Override
public synchronized void close() throws SQLException{
//??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~
總結
以上是生活随笔為你收集整理的mysql memory leak_解决memory leak问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql windows乱码_小白楠-
- 下一篇: java商城开发_javaweb实战之商