Pet*_*kas 12 java tomcat guice guice-servlet
我刚刚开始在我的Tomcat webapp中使用Google Guice,并且只要取消部署WAR文件,就会在catalina.out文件中注意到以下内容:
May 16, 2011 5:37:24 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/app]
May 16, 2011 5:37:24 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: A web application appears to have started a thread named [com.google.inject.internal.util.$Finalizer] but has failed to stop it. This is very likely to create a memory leak.
May 16, 2011 5:37:24 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap SEVERE: A web application created a ThreadLocal with key of type [null] (value [com.google.inject.internal.InjectorImpl$1@10ace8d]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@7e9bed]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.
May 16, 2011 5:37:24 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/app]
May 16, 2011 5:37:24 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: A web application appears to have started a thread named [com.google.inject.internal.util.$Finalizer] but has failed to stop it. This is very likely to create a memory leak.
May 16, 2011 5:37:24 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: A web application created a ThreadLocal with key of type [null] (value [com.google.inject.internal.InjectorImpl$1@10ace8d]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@7e9bed]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.
May 16, 2011 5:37:24 PM org.apache.catalina.startup.HostConfig checkResources
INFO: Undeploying context [/app]
May 16, 2011 5:37:24 PM org.apache.catalina.loader.WebappClassLoader clearReferencesThreads SEVERE: A web application appears to have started a thread named [com.google.inject.internal.util.$Finalizer] but has failed to stop it. This is very likely to create a memory leak.
May 16, 2011 5:37:24 PM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap SEVERE: A web application created a ThreadLocal with key of type [null] (value [com.google.inject.internal.InjectorImpl$1@10ace8d]) and a value of type [java.lang.Object[]] (value [[Ljava.lang.Object;@7e9bed]) but failed to remove it when the web application was stopped. To prevent a memory leak, the ThreadLocal has been forcibly removed.
有谁知道是什么原因引起的,或者我怎么能阻止它发生?
我只按照此处的说明 http://code.google.com/docreader/#p=google-guice&s=google-guice&t=ServletModule
......还没有做过任何想象.我只有2个servlet和一个过滤器.
谢谢!
如果您在关闭网络应用程序时收到此消息,我不会太担心。应用程序上的此类资源泄漏。关机很常见。当您频繁进行热部署(即多次取消部署而不杀死 JVM)时,它们确实会成为问题,但是当完成冷部署时(取消部署/部署是在之前杀死 JVM 的同时完成的),它们不会成为问题重新部署)。
一种常见的策略是在开发期间进行热部署(因为它们通常比冷部署更快),并且仅在资源泄漏开始影响性能时才进行冷部署。然后,在生产中,您对每次部署进行冷部署。考虑到存在此类泄漏的代码/库的数量,在我看来,试图消除它们将是困难的。