This discussion is archived
1 Reply Latest reply: Dec 7, 2012 9:21 AM by 978498 RSS

Memory leak on application undeploy.

978498 Newbie
Currently Being Moderated
We're creating a Spring-based web app that is using a Tomcat 7.0.33 managed Oracle database pool. We're using the ojdbc6.jar to connect (Oracle 10g but migrating to 11g later).

When our application is undeployed in Tomcat we get probable memory leak warnings (see below). After several re-deploys we inevitably run out of PermGen space. I've tried using the ojdbc14 drivers and they didn't seem to have this problem. But we're moving to 11g so we can't use them. I have tried adding a ContextListener that closes the DBCP pool on destroy but that didn't help any. Is this a bug in the Oracle drivers? Is there any way we can mitigate this?

17505 INFO org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean - Closing JPA EntityManagerFactory for persistence unit 'myManager'
17515 INFO org.apache.tiles.access.TilesAccess - Removing TilesContext for context: org.springframework.web.servlet.view.tiles2.SpringTilesApplicationContextFactory$SpringWildcardServletTilesApplicationContext
Dec 06, 2012 6:41:29 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [myApp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1468544]) and a value of type [java.lang.Class] (value [class oracle.sql.AnyDataFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Dec 06, 2012 6:41:29 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [myApp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@d73b31]) and a value of type [java.lang.Class] (value [class oracle.sql.TypeDescriptorFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Dec 06, 2012 6:41:29 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [myApp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@13aae39]) and a value of type [java.lang.Class] (value [class oracle.sql.TypeDescriptorFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Dec 06, 2012 6:41:29 PM org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [myApp] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@18443b1]) and a value of type [java.lang.Class] (value [class oracle.sql.AnyDataFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
Dec 06, 2012 6:41:34 PM org.apache.catalina.startup.HostConfig deleteRedeployResources
INFO: Undeploying context [myApp]
  • 1. Re: Memory leak on application undeploy.
    978498 Newbie
    Currently Being Moderated
    Nevermind - It figures just after I post this I find the solution. And naturally it's not a bug in the ojdbc6.jar drivers. :-)

    It turns out our application was also including ojdbc6.jar in WEB-INF/lib. This caused Tomcat to use our jar for connections and thus the leak was formed. So not deploying ojdbc6.jar with our application (marking it as "provided" in pom.xml) lets Tomcat manage the connections and clean-up our app.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points