gpt4 book ai didi

java - 如何停止由 org.asynchttpclient 创建的线程以防止内存泄漏?

转载 作者:行者123 更新时间:2023-11-28 22:49:31 25 4
gpt4 key购买 nike

我正在使用 org.asynchttpclient 来发布异步请求。

关闭 tomcat 时,我收到以下日志:

SEVERE: The web application [/test] appears to have started a thread named [pool-1-thread-1] but has failed to stop it. This is very likely to create a memory leak.
Jul 04, 2017 10:53:00 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [/test] appears to have started a thread named [AsyncHttpClient-2-1] but has failed to stop it. This is very likely to create a memory leak.
Jul 04, 2017 10:53:00 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [/test] appears to have started a thread named [AsyncHttpClient-2-2] but has failed to stop it. This is very likely to create a memory leak.
Jul 04, 2017 10:53:00 AM org.apache.catalina.loader.WebappClassLoaderBase checkThreadLocalMapForLeaks

SEVERE: The web application [/test] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@71513074]) and a value of type [io.netty.util.internal.InternalThreadLocalMap] (value [io.netty.util.internal.InternalThreadLocalMap@4aecc2e8]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.

如何关闭这些线程以防止内存泄漏。

最佳答案

这更像是一个警告,在大多数情况下可以忽略。当重新加载或关闭上下文时,您将看到此错误。如果您要关闭服务器,那么 JVM 也将关闭,操作系统将清理所有内存。
如果您想尝试在实现 ClosableAsyncHttpClient 上调用关闭,它可能会阻止此问题。您可能必须在那里等待,让它完全关闭连接工厂。您可以查看 tomcat 生命周期以添加关闭处理程序来处理关闭客户端。

关于java - 如何停止由 org.asynchttpclient 创建的线程以防止内存泄漏?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44909955/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com