正常关闭时Tomcat内存泄漏警告 - Codahale

时间:2017-08-04 09:26:37

标签: tomcat thread-local codahale-metrics

我在尝试优雅地关闭tomcat时遇到问题。发出此严重警告,应用程序将挂起,直至终止。在这种情况下似乎与codahale有关,这与另外几个类似的问题不同。有关修复的任何建议。提前谢谢。

(使用Tomcat 7.0.78到Intellij)

created a ThreadLocal with key of type 
[com.codahale.metrics.ThreadLocalRandom$1] (value 
[com.codahale.metrics.ThreadLocalRandom$1@7008afaf]) and a value of 
type [com.codahale.metrics.ThreadLocalRandom] (value 
[com.codahale.metrics.ThreadLocalRandom@cb6fe27]) 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.

1 个答案:

答案 0 :(得分:0)

这是一个未解决的问题:https://github.com/dropwizard/metrics/issues/742

com.codahale.metrics.ThreadLocalRandom是一个由加载Codahale的同一个类加载器加载的类,因此该类可以引用它的类加载器,它可以防止所有其他类被垃圾回收。如果codahale是您的应用程序的一部分,那么您的所有类将不会被垃圾收集。 尝试将codahale放在common / lib而不是你的应用程序中,看看会发生什么。我认为这样可以让你的应用程序被gc-ed。