您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

Tomcat Guice / JDBC内存泄漏

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();
}

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

其他 2022/1/1 18:13:55 有571人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶