简体   繁体   English

如何解决 tomcat 内存泄漏警告 - Web 应用程序已启动一个线程但未能将其停止

[英]How to resolve tomcat memory leak warning - The web application have started a thread but has failed to stop it

I am using com.ning.async-http-client(1.9.40) library to post asynchronous request.我正在使用 com.ning.async-http-client(1.9.40) 库来发布异步请求。 While shutting down tomcat, I am getting below messages in catalina.out log :-在关闭 tomcat 时,我在 catalina.out 日志中收到以下消息:-

SEVERE: The web application [/xyz] appears to have started a thread named [Hashed wheel timer #1] but has failed to stop it. This is very likely to create a memory leak.
Jul 03, 2017 1:27:15 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/xyz] appears to have started a thread named [New I/O worker #1] but has failed to stop it. This is very likely to create a memory leak.
Jul 03, 2017 1:27:15 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/xyz] appears to have started a thread named [New I/O worker #2] but has failed to stop it. This is very likely to create a memory leak.
Jul 03, 2017 1:27:15 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/xyz] appears to have started a thread named [New I/O boss #3] but has failed to stop it. This is very likely to create a memory leak.
Jul 03, 2017 1:27:15 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [/xyz] appears to have started a thread named [Hashed wheel timer #2] but has failed to stop it. This is very likely to create a memory leak.**

The state of these threads are:这些线程的状态是:

"New I/O boss #3" prio=10 tid=0x00007ff3a00f9000 nid=0x17a9 runnable [0x00007ff3878f7000]
"New I/O worker #2" daemon prio=10 tid=0x00007ff3a00aa800 nid=0x17a8 runnable [0x00007ff3879f8000]
"New I/O worker #1" daemon prio=10 tid=0x00007ff3a00b8800 nid=0x17a7 runnable [0x00007ff387af9000]
"Hashed wheel timer #2" prio=10 tid=0x00007ff3a020e800 nid=0x17aa waiting on condition [0x00007ff3875f0000]
"Hashed wheel timer #1" prio=10 tid=0x00007ff3a0083000 nid=0x17a6 sleeping[0x00007ff387bfa000]

Please suggest a way to stop these threads from application.请提出一种从应用程序中停止这些线程的方法。

The AsyncHttpClient implements Closeable . AsyncHttpClient实现Closeable It suffices to call close() on it when your application shuts down.当您的应用程序关闭时,调用close()就足够了。

This will clean up the resources used by AsyncHttpClient .这将清理AsyncHttpClient使用的资源。

To illustrate :举例说明:

public static void main(String[] args) throws Exception {
    AsyncHttpClient asyncHttpClient = new AsyncHttpClient();
    Future<Response> f = asyncHttpClient.prepareGet("http://www.google.com/").execute();
    Response r = f.get();

    asyncHttpClient.close(); // when this is commented out, the application won't exit, as the non daemon threads prevent it.
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 该Web应用程序似乎已启动一个名为的线程,但未能停止该线程。 这很可能造成内存泄漏 - The web application appears to have started a thread named but has failed to stop it. This is very likely to create a memory leak Servlet“已启动一个线程但未能阻止它” - Tomcat中的内存泄漏 - Servlet “has started a thread but failed to stop it” - memory leak in Tomcat Tomcat webapp错误-应用程序启动了线程[AWT-Windows],但未能将其停止-内存泄漏? - Tomcat webapp error - application started thread [AWT-Windows] but has failed to stop it - memory leak? Web应用程序似乎已启动名为[22]的线程但未能阻止它。 这很可能造成内存泄漏 - A web application appears to have started a thread named [22] but has failed to stop it. This is very likely to create a memory leak Web 应用程序似乎启动了一个名为 [Timer-0] 的线程,但未能停止它 - The web application appears to have started a thread named [Timer-0] but has failed to stop it Web应用程序[VehicleRouting]似乎已启动名为[drools-worker-4]的线程,但未能停止它 - The web application [VehicleRouting] appears to have started a thread named [drools-worker-4] but has failed to stop it Quartz2.x:严重:Web应用程序[/ servlet]似乎已启动名为[Thread-4]的线程,但未能停止它 - Quartz2.x: GRAVE: The web application [/servlet] appears to have started a thread named [Thread-4] but has failed to stop it 使用Oracle JDBC驱动程序12c的Tomcat 7上的内存泄漏 - oracle.jdbc.driver线程无法停止 - Memory leak on Tomcat 7 with Oracle JDBC drivers 12c - oracle.jdbc.driver thread failed to stop tomcat关闭内存泄漏,java线程无法停止 - tomcat shutdown memory leak, java thread can not stop 服务器由于[Pool-Cleaner]:Tomcat连接池而停止响应,但未能停止它。 这很可能造成内存泄漏 - Server Stop responding because of [Pool-Cleaner]:Tomcat Connection Pool but has failed to stop it. This is very likely to create a memory leak
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM