Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.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 如何解决tomcat内存泄漏警告-web应用程序已启动一个线程,但未能停止它_Java_Tomcat_Memory Leaks_Asynchttpclient - Fatal编程技术网

Java 如何解决tomcat内存泄漏警告-web应用程序已启动一个线程,但未能停止它

Java 如何解决tomcat内存泄漏警告-web应用程序已启动一个线程,但未能停止它,java,tomcat,memory-leaks,asynchttpclient,Java,Tomcat,Memory Leaks,Asynchttpclient,我正在使用com.ning.asyncHTTPClient(1.9.40)库发布异步请求。关闭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.

我正在使用com.ning.asyncHTTPClient(1.9.40)库发布异步请求。关闭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.**
这些线程的状态为:

"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]

请建议从应用程序中停止这些线程的方法

异步HttpClient实现了
可关闭
。当应用程序关闭时,只需对其调用
close()

这将清理
AsyncHttpClient
使用的资源

举例说明:

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.
}
publicstaticvoidmain(字符串[]args)引发异常{
AsyncHttpClient AsyncHttpClient=新的AsyncHttpClient();
Future f=asyncHttpClient.prepareGet(“http://www.google.com/execute();
响应r=f.get();
asyncHttpClient.close();//当注释掉此项时,应用程序将不会退出,因为非守护进程线程会阻止它退出。
}