Threadpool中的Threadlocal内存泄漏 [英] Threadlocal memory leak in Threadpool

查看:95
本文介绍了Threadpool中的Threadlocal内存泄漏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Tomcat中遇到threadlocal内存泄漏错误,我正在使用ThreadPool,但我的webapp中没有ThreadLocal的实现。

I am getting threadlocal memory leak errors in Tomcat and I am using ThreadPool, but have no implementation of ThreadLocal in my webapp.


严重:Web应用程序[/ myWebApp]创建了一个ThreadLocal,其键类型为[org.a
pache.http.impl.cookie.DateUtils $ DateFormatHolder $ 1](value [org.apache.http.imp
l.cookie.DateUtils$DateFormatHolder$1@4c2849])和类型为[java.lang.re
f.SoftReference]的值(值[java.lang.ref.SoftReference@1e67280])但未能成为rem当Web应用程序停止时,
。线程将被续订超过
r时间以尝试避免可能的内存泄漏。

SEVERE: The web application [/myWebApp] created a ThreadLocal with key of type [org.a pache.http.impl.cookie.DateUtils$DateFormatHolder$1] (value [org.apache.http.imp l.cookie.DateUtils$DateFormatHolder$1@4c2849]) and a value of type [java.lang.re f.SoftReference] (value [java.lang.ref.SoftReference@1e67280]) but failed to rem ove it when the web application was stopped. Threads are going to be renewed ove r time to try and avoid a probable memory leak.

我不明白为什么我收到threadlocal错误,虽然我没有实现它?我想摆脱这些消息,所以我搜索了网页,并在这里写的是为了清理我需要使用的threadlocal:

What I dont understand is why i am getting threadlocal error although i have not implemented it? I want to get rid of these messages so I searched the web, and in here it is written that in order to clean the threadlocal i need to use:

ThreadLocal.remove()

但我没有ThreadLocal的实现..如果有人给我指路,我将不胜感激。

but I have no implementation of ThreadLocal.. I'll be appreciated if someone show me a way.

推荐答案

显然,某些东西正在创建那些/那些ThreadLocal实例。如果它不是你的代码,那么它必须是你正在使用的某个库,或者(不太可能)Tomcat本身。

Clearly, something is creating that / those ThreadLocal instances. If it is not your code, then it must be some library you are using, or (unlikely) Tomcat itself.

我将从查看可能正在创建实例的内容开始of

I would start by looking at what might be creating instances of

    org.apache.http.impl.cookie.DateUtils$DateFormatHolder$1

(顺便说一句,这是 DataUtils 中嵌套类中的匿名类...所以除非出现奇怪的事情,否则将在 DateUtils.java 文件中创建。)

(That's an anonymous class in a nested class in DataUtils, by the way ... so unless something weird is coing on, the creation will be occuring in the DateUtils.java file.)

如果检查源代码没有帮助,尝试调试Tomcat实例并在ThreadLocal构造函数上设置断点。

If examining the source code doesn't help, try debugging the Tomcat instance and setting a breakpoint on the ThreadLocal constructor(s).

这篇关于Threadpool中的Threadlocal内存泄漏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆