Tomcat GuiceJDBC内存泄漏

Tomcat GuiceJDBC内存泄漏,第1张

Tomcat Guice / JDBC内存泄漏

我自己解决了这个问题。与其他答案相反,我不建议发出该

t.stop()
命令。此方法已被弃用,这是有充分理由的。请参考Oracle这样做的原因。

但是,有一种解决方案可以消除此错误,而无需诉诸

t.stop()

您可以使用提供的大多数代码@Oso,只需替换以下部分

Set<Thread> threadSet = Thread.getAllStackTraces().keySet();Thread[] threadArray = threadSet.toArray(new Thread[threadSet.size()]);for(Thread t:threadArray) {    if(t.getName().contains("Abandoned connection cleanup thread")) {        synchronized(t) { t.stop(); //don't complain, it works        }    }}

使用MySQL驱动程序提供的以下方法替换它:

try {    AbandonedConnectionCleanupThread.shutdown();} catch (InterruptedException e) {    logger.warn("SEVERE problem cleaning up: " + e.getMessage());    e.printStackTrace();}

这应该正确地关闭线程,并且错误应该消失。



欢迎分享,转载请注明来源:内存溢出

原文地址:https://www.54852.com/zaji/4909413.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-12
下一篇2022-11-12

发表评论

登录后才能评论

评论列表(0条)

    保存