We are using Oracle the UCP driver (Oracle Universal Connection Pool) in tomcat 6. It is more or less configured like in Oracles Howto. The problem is that the driver starts a lot of threads (Thread-0 to 57, UCP-worker-thread-1 to 24) which aren't stopped when the server shuts down - tomcat emits loads of error messages like this:
The web application [/xxx] appears to have started a thread named [Timer-17] but has failed to stop it. This is very likely to create a memory leak.
Any idea how to deal with this?
I had the same problem and managed to fix this by adding the following code in my ServletContextListener
:
import oracle.ucp.admin.UniversalConnectionPoolManager;
import oracle.ucp.admin.UniversalConnectionPoolManagerImpl;
public class MyContextListener implements ServletContextListener {
/* ... */
@Override
public void contextDestroyed(ServletContextEvent sce) {
// Your shutdown sequence here
/* ... */
// Shutdown UCP if present, to avoid warnings about thread leaks
UniversalConnectionPoolManager ucpManager = UniversalConnectionPoolManagerImpl.getUniversalConnectionPoolManager();
if (ucpManager != null) {
String[] poolNames = ucpManager.getConnectionPoolNames();
if (poolNames != null) {
for (String poolName : poolNames) {
ucpManager.destroyConnectionPool(poolName);
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With