Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 内存泄漏-度量计勾选线程和新的I/O客户端工作线程_Java_Spring Mvc_Memory Leaks_Titan_Datastax Java Driver - Fatal编程技术网

Java 内存泄漏-度量计勾选线程和新的I/O客户端工作线程

Java 内存泄漏-度量计勾选线程和新的I/O客户端工作线程,java,spring-mvc,memory-leaks,titan,datastax-java-driver,Java,Spring Mvc,Memory Leaks,Titan,Datastax Java Driver,我正在运行SpringMVC应用程序。当我关闭Tomcat服务器时,它显示 SEVERE: The web application [/myapp] appears to have started a thread named [metrics-meter-tick-thread-1] but has failed to stop it. This is very likely to create a memory leak. SEVERE: The web application [/myap

我正在运行SpringMVC应用程序。当我关闭Tomcat服务器时,它显示

SEVERE: The web application [/myapp] appears to have started a thread named [metrics-meter-tick-thread-1] but has failed to stop it. This is very likely to create a memory leak.
SEVERE: The web application [/myapp] appears to have started a thread named [metrics-meter-tick-thread-2] but has failed to stop it. This is very likely to create a memory leak.
还有这个:

SEVERE: The web application [/myapp] appears to have started a thread named [New I/O client worker #1-3] but has failed to stop it. This is very likely to create a memory leak.

SEVERE: The web application [/anant] created a ThreadLocal with key of type [org.jboss.netty.util.CharsetUtil$2] (value [org.jboss.netty.util.CharsetUtil$2@5db3978d]) and a value of type [java.util.IdentityHashMap] (value [{UTF-8=sun.nio.cs.UTF_8$Decoder@39a2da0a}]) 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.
这个人不知道与哪个罐子相关,可能是
netty

当我探索JAR依赖性时,我发现有两个
度量核心
JAR:

metrics-core:2.2.0 (used by `datastax`)
metrics-core:3.0.1 (used by `Titan`)
我附加了所有的快照,以使其更清晰。那么解决方案是什么呢

我正在使用

jdk1.7
cassandra-driver-core-1.0.4
titan-0.4.4
cassandra-1.2.2
tomcat-7.0.34


检查您的Web应用程序或某个库中的线程*线程启动了什么。并在关闭应用程序之前停止线程。 请参阅Tomcat wiki,它解释了如何创建内存泄漏。它还解释了未清理的ThreadLocal变量如何导致内存泄漏

webapps产生的线程

如果webapp创建线程,默认情况下 其上下文类加载器设置为父线程( 创建新线程的线程)。在webapp中,此父线程 是tomcat工作线程之一,其上下文类加载器设置为 webapp类加载器在执行webapp代码时

此外,生成的线程可能正在执行(或阻塞)某些 涉及webapp加载的类的代码,从而防止 正在收集webapp类加载器

因此,如果生成的线程在 应用程序已停止,webapp类加载器将泄漏,因为 派生线程持有的强引用


我知道我来晚了一点。我也有同样的问题,最终找到了解决办法。问题在于metrics 2.2 JAR(产生这些线程)使用了Oracle建议的
ManagementFactory.getPlatformMBeanServer()
方法。此类位于
java.lang
包中,因此它将由VM集中加载,而不是针对每个模块。因此,由于Metrics包只会在VM退出时关闭这些线程(通过添加关闭挂钩),因此加载此包的classloader会让通过包指定的
MXBeans
在模块卸载时保留。更糟糕的是,加载war文件的classloader也将保持加载在VM上,VM还将(传递)包括模块中加载的任何类和任何静态


您可以手动调用
Metrics.shutdown()
,这有时可以解决问题。我确实在这个解决方案中遇到了一些奇怪的问题(有时线程在此之后仍然存在,但我有一个非常特殊的设置,不想在这个问题上再浪费时间)。

它只是由库启动的,所以我无法停止。查看库的更新版本是否可用或报告此错误。如何?你能提供一些参考或例子吗