but has failed to stop it. This is very likely to create a memory leak(c3p0在Spring管理中,连接未关闭导致的内存溢出)

以下是错误日志信息:

严重: The web application [/news] registered the JDBC 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.
2014-12-19 0:27:47 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/news] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1pyjusp96q571f188m8|18782a7]-AdminTaskTimer] but has failed to stop it. This is very likely to create a memory leak.
2014-12-19 0:27:47 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/news] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1pyjusp96q571f188m8|18782a7]-HelperThread-#0] but has failed to stop it. This is very likely to create a memory leak.
2014-12-19 0:27:47 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/news] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1pyjusp96q571f188m8|18782a7]-HelperThread-#1] but has failed to stop it. This is very likely to create a memory leak.
2014-12-19 0:27:47 org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
严重: The web application [/news] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->1pyjusp96q571f188m8|18782a7]-HelperThread-#2] but has failed to stop it. This is very likely to create a memory leak.


堆栈信息:

Exception in thread "C3P0PooledConnectionPoolManager[identityToken->1pyjusp96q571f188m8|18782a7]-AdminTaskTimer" java.lang.NullPointerException
    at com.mchange.v2.log.log4j.Log4jMLog$Log4jMLogger.isLoggable(Log4jMLog.java:293)
    at com.mchange.v2.async.ThreadPoolAsynchronousRunner$DeadlockDetector.run(ThreadPoolAsynchronousRunner.java:729)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)



我的情况是在配置数据源时未配置销毁dataSource对象时执行close方法关闭连接

	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" >
		<property name="driverClass" value="${driverClass}"></property>
		<property name="jdbcUrl" value="${jdbcUrl}"></property>
		<property name="user" value="${user}"></property>
		<property name="password" value="${password}"></property>

		<property name="initialPoolSize" value="1"></property>
		<property name="minPoolSize" value="1"></property>
		<property name="maxPoolSize" value="20"></property>
		<property name="maxIdleTime" value="60"></property>
	</bean>

<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" > 在这里面加入destroy-method="close"

原文地址:https://www.cnblogs.com/37sky/p/5055551.html