我已经使用Clojure创建了一个Web应用程序,将其打包成WAR文件,并在Tomcat上部署。它按照我的预期工作,但是当我尝试关闭Tomcat时,我看到很多异常,如下所示:
SEVERE: The web application [] created a ThreadLocal with key of type
[java.lang.ThreadLocal] (value [java.lang.ThreadLocal@fc5408]) and a value of type [clojure.lang.LockingTransaction] (value [clojure.lang.LockingTransaction@12db7c]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 17, 2011 4:19:48 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [] created a ThreadLocal with key of type [null] (value [clojure.lang.Var$1@11de914]) and a value of type [clojure.lang.Var.Frame] (value [clojure.lang.Var$Frame@7c28c]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
Mar 17, 2011 4:19:48 AM org.apache.catalina.loader.WebappClassLoader clearThreadLocalMap
SEVERE: The web application [] created a ThreadLocal with key of type [null] (value [clojure.lang.Var$1@11de914]) and a value of type [clojure.lang.Var.Frame] (value [clojure.lang.Var$Frame@17588d5]) but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
我知道Clojure有时可能会超越Java垃圾回收器的一些事情。我的war文件有一个ServletContextListener,它启动了一些后台线程,但我认为当上下文卸载时,这些线程应该优雅地终止(毕竟它们不是守护线程)。
也许有更好/不同的方法可以使用来启动我的线程,更适合Tomcat?现在我只是通过调用
(future(loop ...
来启动它们。