javaspringtomcatguavabonecp

Tomcat memory leak - Stopping Guava Finalizer thread


I have a Spring web application running on Tomcat.

When trying to shutdown Tomcat with the shutdown.sh script, the java process doesn't end because it has a Thread that's still running. The catalina.log contains

Jul 22, 2013 2:07:50 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/myapp] appears to have started a thread named [com.google.common.base.internal.Finalizer] but has failed to stop it. This is very likely to create a memory leak.

Apparently BoneCP has some Guava integration that causes this thread to block. Is there a clean or intended way to kill this thread?


Solution

  • There's an open issue on Guava for this problem - the issue itself is pretty old but if you check the latest comments you'll see some suggestions from other BoneCP users to resolve this issue

    Also check this other issue and this patch