1

Similar to my question here Spring Tomcat C3P0PooledConnectionPoolManager creates a memory leak I wish to understand why Spring or C3P0 itself not cleaning up the threads it creates on shutdown?

I get the following logs in Tomcat

SEVERE: The web application [/ul-xtrain] appears to have started a thread named [C3P0PooledConnectionPoolManager[identityToken->2wpukr9b7ohfj11xtbfft|725548e3]-AdminTaskTimer] but has failed to stop it. This is very likely to create a memory leak.

I am not interested in solution as I already have working solution based on these threads

Hibernate4 + c3p0 + Derby - Memory Leak on Tomcat stop or web application reload

Tomcat Guice/JDBC Memory Leak

To prevent a memory leak, the JDBC Driver has been forcibly unregistered

I just wish to understand why Spring is not closing it. Thank you

Community
  • 1
  • 1
  • Because spring has nothing to do with it, this is a C3P0 thing not a Spring thing. – M. Deinum Aug 12 '15 at 05:38
  • It's not a c3p0 thing or a Spring thing. It is a webapp thing. If your webapp opens resources (like c3p0 DataSources, which in turn open up Threads), it should close those resources on application shutdown. Ideally, you set up resources like Connection pools in the `contextInitialized` method of a `ServletContextListener`, and you clean up those resources in the `contextDestroyed` method. as far as I know (which may not be very far, i don't use Spring much), Spring does not have any means of responding to webapp shutdown on its own. – Steve Waldman Aug 12 '15 at 11:56
  • See also http://www.mchange.com/projects/c3p0/#tomcat-specific and http://www.mchange.com/projects/c3p0/#configuring_to_avoid_memory_leaks_on_redeploy especially if you are creating DataSource instances that are shared by and outlive individual webapps. – Steve Waldman Aug 12 '15 at 11:59
  • I just start up and close the webapp without accessing and i get these SEVERE log. – Jonathan O. Tan Aug 14 '15 at 00:01

0 Answers0