启动名为MultiThreadedHttpConnectionManager清理线程,但未能阻止它 [英] Started a thread named MultiThreadedHttpConnectionManager cleanup but has failed to stop it

查看:2060
本文介绍了启动名为MultiThreadedHttpConnectionManager清理线程,但未能阻止它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写使用亚马逊网络服务AWS Java SDK的Web应用程序。 Apache的Commons的HttpClient版本号为3幕后。我有公地httpclient的-3.0.1.jar包括在内。

我有以下警告我catalina.out的

 重度:Web应用程序[/ MyAppName]似乎已经开始了一个名为线程
[MultiThreadedHttpConnectionManager清理],但未能阻止它。这是
很可能造成内存泄漏。
 

所以,我写了一个的ServletContextListener与contextDestroyed()方法调用:

  MultiThreadedHttpConnectionManager.shutdownAll();
 

然而,该警告还表示,尽管该方法被调用。还有哪些我应该做的,以确保清理?

修改:我想绝对确保contextDestroyed()确实叫(上号的建议),所以我放在方法的第一个语句设置一个断点,停止服务器和断点腹背受敌我执行一步的方法步骤,以确保异常不提高,该方法的每一行没有问题被执行死刑。下面是我的源$ C ​​$ C:

  @覆盖
公共无效contextDestroyed(ServletContextEvent servletContextEvent){
    的System.out.println(contextDestroyed()启动);
    MyMemCache.shutDown();
    MultiThreadedHttpConnectionManager.shutdownAll();
    ClassLoader的contextClassLoader = Thread.currentThread()getContextClassLoader()。
    LogFactory.release(contextClassLoader);
    java.beans.Introspector.flushCaches();
    的System.out.println(contextDestroyed()结束);
}
 

当热插拔:

 信息:重装上下文的名称[/ MyAppName]开始
contextDestroyed()启动
contextDestroyed()结束
05 24,11下午3点11分零零秒org.apache.catalina.loader.WebappClassLoader
    clearReferencesThreads
重度:Web应用程序[/ MyAppName]似乎已经开始了一个线程
    名为[MultiThreadedHttpConnectionManager清理],但未能
    停下来。这很可能造成内存泄漏。
 

解决方案

更​​新到AWS的Java SDK 1.2.1版解决了这个问题。这个版本是尚未公布的时候我张贴的问题,因为它是5月26日,2011年发布的

AWS SDK 1.2。*使用HttpClient的4,在2009年发布,但AWS的Java SDK仍在使用其1.1版本3。*版本。我不打算在进一步的细节,分析其code的变化,因为我的问题就解决了​​。

I am writing a web application using Amazon Web Services AWS Java SDK. Apache commons HttpClient version 3 is used behind the scenes. I have commons-httpclient-3.0.1.jar included.

I have the following warning in my catalina.out

SEVERE: The web application [/MyAppName] appears to have started a thread named
[MultiThreadedHttpConnectionManager cleanup] but has failed to stop it. This is 
very likely to create a memory leak.

So I wrote a ServletContextListener with contextDestroyed() method calling:

MultiThreadedHttpConnectionManager.shutdownAll();

However, the warning still shows, despite the method is been called. What else should I do to ensure cleanup?

EDIT: I wanted to be absolutely sure that contextDestroyed() was indeed called (on suggestion of nos), so I placed a breakpoint on the first statement of the method, stopped the server and the breakpoint got hit I executed the method step by step to be sure that exceptions are not raised, and every line of the method was executed without problem. Here is my source code:

@Override
public void contextDestroyed(ServletContextEvent servletContextEvent) {
    System.out.println("contextDestroyed() start");
    MyMemCache.shutDown();
    MultiThreadedHttpConnectionManager.shutdownAll();
    ClassLoader contextClassLoader=Thread.currentThread().getContextClassLoader();
    LogFactory.release(contextClassLoader);
    java.beans.Introspector.flushCaches();
    System.out.println("contextDestroyed() end");
}

When hot swapping:

INFO: Reloading Context with name [/MyAppName] has started
contextDestroyed() start
contextDestroyed() end
05 24, 11 3:11:00 PM org.apache.catalina.loader.WebappClassLoader 
    clearReferencesThreads
SEVERE: The web application [/MyAppName] appears to have started a thread 
    named [MultiThreadedHttpConnectionManager cleanup] but has failed to 
    stop it. This is very likely to create a memory leak.

解决方案

Updating to AWS Java SDK version 1.2.1 solved the problem. This version was not available yet when I posted the question, since it was released on May 26, 2011.

AWS SDK 1.2.* uses HttpClient 4, released in 2009, but AWS Java SDK was still using version 3 in its 1.1.* versions. I won't go in further details to analyze their code changes since my problem is solved.

这篇关于启动名为MultiThreadedHttpConnectionManager清理线程,但未能阻止它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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