0

As per configuring_to_avoid_memory_leaks, I have configured c3p0 by setting contextClassLoaderSource= library and privilegeSpawnedThreads=true but still on tomcat shutdown I receive plenty of WARNING and SEVERE logs. posting tomcat shutdown log on other website as it's too large to post here.

Shutdown log

In short I can see three types of logs again and again

 WARNING: AccessControlContext of javax.imageio.spi.IIORegistry used
 custom combiner - unsetting

 WARNING: JDBC driver loaded by protected ClassLoader deregistered:
 class com.mysql.cj.jdbc.Driver 
 Sep 14, 2018 10:55:18 AM
 se.jiderhamn.classloader.leak.prevention.JULLogger warn WARNING: MBean
 'com.mchange.v2.c3p0:type=C3P0Registry' was loaded by protected
 ClassLoader; unregistering 
 Sep 14, 2018 10:55:18 AM
 se.jiderhamn.classloader.leak.prevention.JULLogger warn WARNING: MBean
 'com.mchange.v2.c3p0:type=PooledDataSource,identityToken=2ryr879x1niyl781nuvflb|3a05d421,name=2ryr879x1niyl781nuvflb|3a05d421' was loaded by protected ClassLoader; unregistering 
Sep 14, 2018 10:55:18 AM se.jiderhamn.classloader.leak.prevention.JULLogger error
 SEVERE: Internal registry of java.beans.PropertyEditorManager not
 found

 Sep 14, 2018 10:55:18 AM
 se.jiderhamn.classloader.leak.prevention.JULLogger warn WARNING:
 Stopping Timer thread
 'C3P0PooledConnectionPoolManager[identityToken->2ryr879x1niyl781nuvflb|3a05d421]-AdminTaskTimer'
 running in protected ClassLoader. Thread stack trace:      at
 java.lang.Object.wait(Native Method)   at
 java.util.TimerThread.mainLoop(Timer.java:552)     at
 java.util.TimerThread.run(Timer.java:505)

 Sep 14, 2018 10:55:28 AM
 org.apache.catalina.loader.WebappClassLoaderBase
 clearReferencesThreads SEVERE: The web application [/OES-CLIENTWeb]
 appears to have started a thread named
 [C3P0PooledConnectionPoolManager[identityToken->2ryr879x1niyl781nuvflb|3a05d421]-HelperThread-#0]
 but has failed to stop it. This is very likely to create a memory
 leak.

whether am I missing some config or anything?

I am using:

  • JDK= 8
  • c3p0=0.9.5.2
  • ClassLoaderLeakPreventor= 2.6.1
  • javax.servlet-api=3.0.1
Amogh
  • 4,453
  • 11
  • 45
  • 106
  • Are you shutting down C3P0? Or just ripping down that web application and hoping for the best? Because, as you have already discovered - hope is not enough. – Boris the Spider Sep 14 '18 at 06:18
  • @BoristheSpider Yes, as per https://stackoverflow.com/questions/13532302/how-to-shutdown-connection-pool-on-context-unload I have added the `bean` in `root-context.xml` – Amogh Sep 14 '18 at 06:28
  • The `close()` function of a c3p0 `DataSource` is asynchronous, which means that even if you have properly created a `ServletContextListener` that shuts down the `DataSource`, the threads may not close before your leak watcher checks them. But they should `close()` very quickly. You may have a warning of a memory leak that is ultimately not a memory leak. – Steve Waldman Sep 14 '18 at 07:10
  • @SteveWaldman, Okay. but now I tried to call `close()` method of `ComboPooledDataSource` in `contextDestroyed()`. As per https://www.mchange.com/projects/c3p0/#cleaning we can call `close()` to cleanup the DataSource. But still getting the same logs on shutdown. Looks like leak watcher is executing much much before `contextDestroyed()` isn't it? – Amogh Sep 14 '18 at 07:28
  • No. The leak watcher certainly isn't executing before `contextDestroyed`. – Boris the Spider Sep 15 '18 at 07:34

0 Answers0