温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

tomcat停止出现内存泄漏

发布时间:2020-08-01 07:49:07 来源:网络 阅读:11075 作者:yinguo0304 栏目:开发技术

SEVERE: The web application [] registered the JDBC driver [com.alibaba.druid.proxy.DruidDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc

SEVERE: The web application [] registered the JDBC driver [com.mysql.jdbc.Driver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-1] but has failed to stop it. This is very likely to create a memory leak.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-2] but has failed to stop it. This is very likely to create a memory leak.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-3] but has failed to stop it. This is very likely to create a memory leak.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-4] but has failed to stop it. This is very likely to create a memory leak.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-5] but has failed to stop it. This is very likely to create a memory leak.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-6] but has failed to stop it. This is very likely to create a memory leak.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-7] but has failed to stop it. This is very likely to create a memory leak.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-8] but has failed to stop it. This is very likely to create a memory leak.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-9] but has failed to stop it. This is very likely to create a memory leak.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [startQuartz_Worker-10] but has failed to stop it. This is very likely to create a memory leak.

Jun 30, 2018 8:57:08 AM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads

SEVERE: The web application [] appears to have started a thread named [Abandoned connection cleanup thread] but has failed to stop it. This is very likely to create a memory leak.

以上是tomcat报出的错误信息。




原因分析:通过查询大量资料,同时结合自己的项目情况,分析得出引起tomcat memory leak 的原因有:

       1、jdbc Driver在tomcat运行时进行注册,但是当tomcat停止时没有解除注册;

       2、使用quartz跑定时任务时,tomcat停了,quartz的线程没有停掉;

       3、web 容器重启一个叫Abandoned connection cleanup thread的线程失败.

解决办法:

        1、用脚本语言代替quartz的定时任务或将quartz与业务代码剥离开来;

        2、手动反注册jdbc驱动,清理Abandoned connection cleanup thread。

import com.mysql.jdbc.AbandonedConnectionCleanupThread;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import java.sql.DriverManager;
import java.sql.SQLException;

/**
 * Created by yinguo on 2018-06-26.
 */
public class QuartzContextListener implements ServletContextListener {

    @Override
    public void contextDestroyed(ServletContextEvent arg0) {
        System.out.println("webService stop");
        try {
            while(DriverManager.getDrivers().hasMoreElements()) {
                DriverManager.deregisterDriver(DriverManager.getDrivers().nextElement());
            }
            System.out.println("jdbc Driver close");
            AbandonedConnectionCleanupThread.shutdown();
            System.out.println("clean thread success");
        } catch (SQLException e) {
            e.printStackTrace();
        }catch (InterruptedException e){
            e.printStackTrace();
        }
    }
    @Override
    public void contextInitialized(ServletContextEvent arg0) {
        System.out.println("webService start");
    }
}

        最后再说一点,解决方案千篇一律,还是要具体问题具体分析!!!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI