Postgresql 在tomcat 8上部署clojure环应用程序时出现内存泄漏错误

Postgresql 在tomcat 8上部署clojure环应用程序时出现内存泄漏错误,postgresql,tomcat,memory-leaks,clojure,korma,Postgresql,Tomcat,Memory Leaks,Clojure,Korma,我正试图在Tomcat8上部署一个环形应用程序war。使用lein-ring-uberwar创建了战争 我怀疑这是因为jdbc连接线程,但不确定 我正在使用 [org.postgresql/postgresql“9.4-1206-jdbc42”]和[korma“0.4.1”] project.clj :ring {:handler hello-world.handler/app :init hello-world.handler/init :dest

我正试图在Tomcat8上部署一个环形应用程序war。使用
lein-ring-uberwar
创建了战争

我怀疑这是因为jdbc连接线程,但不确定

我正在使用
[org.postgresql/postgresql“9.4-1206-jdbc42”]
[korma“0.4.1”]

project.clj

  :ring {:handler hello-world.handler/app
         :init    hello-world.handler/init
         :destroy hello-world.handler/destroy}
handler.clj

(korma.db/defdb db (korma.db/postgres {:db "hello_world"
                                       :user "user"
                                       :password "password"
                                       :host "localhost"}))

(defn init []
  (println "Init..."))

(defn destroy []
  (-> (korma.db/connection-pool db) :datasource .close))

这是tomcat日志中的错误跟踪-

org.apache.catalina.startup.HostConfig deployWAR
INFO: Deploying web application archive /var/lib/tomcat7/webapps/hello-world-0.1.0-SNAPSHOT-standalone.war
org.apache.catalina.core.StandardContext startInternal
SEVERE: Error listenerStart
org.apache.catalina.core.StandardContext startInternal
SEVERE: Context [/hello-world-0.1.0-SNAPSHOT-standalone] startup failed due to previous errors
org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/hello-world-0.1.0-SNAPSHOT-standalone] appears to have started a thread named [clojure-agent-send-off-pool-0] but has failed to stop it. This is very likely to create a memory leak.
org.apache.catalina.loader.WebappClassLoader clearReferencesThreads
SEVERE: The web application [/hello-world-0.1.0-SNAPSHOT-standalone] appears to have started a thread named [clojure-agent-send-off-pool-1] but has failed to stop it. This is very likely to create a memory leak.
org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/hello-world-0.1.0-SNAPSHOT-standalone] created a ThreadLocal with key of type [clojure.lang.Var$1] (value [clojure.lang.Var$1@3a2ddd4f]) and a value of type [clojure.lang.Var.Frame] (value [clojure.lang.Var$Frame@191c8b60]) 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.
org.apache.catalina.loader.WebappClassLoader checkThreadLocalMapForLeaks
SEVERE: The web application [/hello-world-0.1.0-SNAPSHOT-standalone] created a ThreadLocal with key of type [clojure.lang.Var$1] (value [clojure.lang.Var$1@3a2ddd4f]) and a value of type [clojure.lang.Var.Frame] (value [clojure.lang.Var$Frame@21025881]) 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.

重新创建问题的代码是否完整?或者您省略了一些可能使用线程局部变量的代码(例如,通过使用动态变量)?我没有使用动态变量、引用、原子等。是的,我省略了一些路由和db查询代码。但是我猜那些查询和控制器操作不会产生这样的问题。我也粘贴了Tomcat7的错误跟踪,但是相同的跟踪出现在Tomcat8中。没有区别。在重新部署应用程序后,您可以获取堆转储,并检查该
var
的GC根以及它所持有的值。它可能会回答您的问题谁是罪魁祸首。堆转储无法捕获那些
var
。在到达堆转储之前,tomcat会终止部署,但出现此异常。还有其他方法吗?是完整的代码重新创建了问题吗?或者您省略了一些可能使用线程局部变量的代码(例如,通过使用动态变量)?我没有使用动态变量、引用、原子等。是的,我省略了一些路由和db查询代码。但是我猜那些查询和控制器操作不会产生这样的问题。我也粘贴了Tomcat7的错误跟踪,但是相同的跟踪出现在Tomcat8中。没有区别。在重新部署应用程序后,您可以获取堆转储,并检查该
var
的GC根以及它所持有的值。它可能会回答您的问题谁是罪魁祸首。堆转储无法捕获那些
var
。在到达堆转储之前,tomcat会终止部署,但出现此异常。还有别的办法吗?