failed to remove it when the web application was stopped. Threads are going to be renewed over time
2017-03-17 21:11
1026 查看
该error的原因:
tomcat关闭应用时的清理工作(3): ThreadLocal
这个泄露其实是可能造成classloader的泄露,因为
解决方案:
private static ThreadLocal<MyClass> tl = new ThreadLocal<MyClass>();
try{
// doSomething()
} finally {
tl.remove();
}
tomcat关闭应用时的清理工作(3): ThreadLocal
这个泄露其实是可能造成classloader的泄露,因为
ThreadLocal引用了自定义的类
MyClass,绑定到了当前的请求线程上,而请求线程又是线程池里的线程,生存周期可能会比较长。比如上面模拟的情况,要停止应用的时候,请求线程的
ThreadLocal仍未释放,那么即使加载
MyClass类的classLoader已经不会再被任何地方使用,可以被垃圾回收了,却因为这个
MyClass被引用而得不到回收。
解决方案:
private static ThreadLocal<MyClass> tl = new ThreadLocal<MyClass>();
try{
// doSomething()
} finally {
tl.remove();
}
相关文章推荐
- 错误:created a ThreadLocal with key of type ……but failed to remove it when the web application was stopped. This is very likely to create a memory leak.
- tomcat停止时,日志failed to remove it when the web application was stopped.
- The web application registered the JDBC driver * but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
- registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
- registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped.
- [tomcat启动报错]registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped
- registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. (转)
- The web application [ ] registered the JDBC driver [net.sourceforge.jtds.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver
- Threads are going to be renewed over time to try and avoid a probable memory leak.
- Threads are going to be renewed over time to try and avoid a probable memory leak.
- application registered the JDBC driver [com.mysql] but failed to unregister it when the web app...
- 警告: The web application [ROOT] appears to have started a thread named [Thread-48] but has failed to stop it. This is very likely to create a memory leak. Stack trace of thread:
- The service cannot be activated because it does not support ASP.NET compatibility. ASP.NET compatibility is enabled for this application. Turn off ASP.NET compatibility mode in the web.config or add the AspNetCompatibilityRequirements attribute to the ser
- but failed to unregister it when the web .....
- 严重: The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it.
- A web application registered the JBDC driver [oracle.jdbc.OracleDriver] but failed to unregister it
- the web application registered the jbdc driver but failed unregistered it when application stoped
- 每日刷题(2015/6/23)You are given the source to an application which crashes when it is run.
- An attempt was made to load a program with an incorrect format” even when the platforms are the same
- 802.11 WDS how does it work, when to use it and what are the limitations