关于tomcat在关闭时的memory leak日志信息的解释
来源:互联网 发布:淘宝c店开店流程 编辑:程序博客网 时间:2024/06/09 22:45
关于tomcat在关闭时的memory leak日志信息的解释:
现象:在shutdown掉tomcat的时候出现一些如下异常:
May 16, 2017 10:28:50 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesJdbc
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.
May 16, 2017 10:28:50 PM 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.
May 16, 2017 10:28:50 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [FileWatchdog] but has failed to stop it. This is very likely to create a memory leak.
May 16, 2017 10:28:50 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [New I/O server boss #1 ([id: 0x445212ca, /0.0.0.0:20881])] but has failed to stop it. This is very likely to create a memory leak.
May 16, 2017 10:28:50 PM org.apache.catalina.loader.WebappClassLoaderBase clearReferencesThreads
SEVERE: The web application [] appears to have started a thread named [dubbo-remoting-server-heartbeat-thread-1] but has failed to stop it. This is very likely to create a memory leak
在查询tomcat的官方解释中有个链接https://wiki.apache.org/tomcat/MemoryLeakProtection详细的阐述了tomcat自6.0.25版本后的内存泄漏检测和修复保护机制。
在关于JDBC driver部分是这样解释的:
If a webapp contains a JDBC driver (e.g. in WEB-INF/lib), the driver will be registered with theDriverManager when it is first used. When the application is stopped, the driver should be deregistered withDriverManager to avoid a classloader leak. Since applications usually forget this, tomcat helps by deregistering the driver.
大体意思:如果应用包含了JDBC驱动包在WEB-INF/lib下(也就是使用到了数据库驱动),当驱动第一次被使用到时就会被驱动管理器注册。当应用在停止时,为避免类加载泄漏,此时驱动应该被驱动管理注销掉。但是自从应用经常忘记做这个事情,tomcat就帮助强制注销此驱动,也就有了日志的出现—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.
此时知道大概原因,就去DruidDriver里面看看有没有做DriverManager.deRegisterDriver(driver)方法了,在经过查看DruidDriver类只发现了DriverManager.registerDriver(driver);
而没有调用过DriverManager.deRegisterDriver(driver);
由此可以看出问题的原因了。经过查看com.mysql.jdbc.Driver,也是没有注销的方法。
解决方法:
1.写个子类继承Driver然后实现DriverManager.deRegisterDriver(driver)方法。
2.在tomcat中配置不打印这些异常。
3.也可以不管这个异常
- 关于tomcat在关闭时的memory leak日志信息的解释
- 关闭tomcat时提示memory leak警告解决办法
- 关闭tomcat的一些日志信息
- 关于memory leak这词的翻译。。。。
- 烦人的memory leak
- Java的Memory leak
- 关于struts和Tomcat7报告:Memory Leak 的问题。
- 简单的Memory leak跟踪
- Pthread导致的memory leak
- tomcat memory leak
- 在Android 项目时的防止Memory leak 要注意的事项
- 在Android 项目时的防止Memory leak 要注意的事项
- 在Android 项目时的防止Memory leak 要注意的事项
- 在Android 项目时的防止Memory leak 要注意的事项
- 在Android 项目时的防止Memory leak 要注意的事项
- 在Android 项目时的防止Memory leak 要注意的事项
- 在Android 项目时的防止Memory leak 要注意的事项
- 采用数据库连接池连接到mysql时,因应用中没有关闭ResultSet导致的memory leak问题
- 以高斯塞德尔法和牛顿拉夫逊法为思想的基于Matlab的电力系统潮流计算
- hdu 5692 Snacks(dfs序+线段树)
- 3-7 DNA序列(DNA Consensus String, ACM/ICPC Seoul 2006, UVa1368)
- javaee加密部署,tomcat使用自己的classloader解密
- 无人机跟踪系统项目开发过程记录-1
- 关于tomcat在关闭时的memory leak日志信息的解释
- jsonp跨域
- python界面开发
- 详解JS中Number()、parseInt()和parseFloat()的区别
- Ffmpeg(Fast Forward mpeg)用法总结(上)
- div添加背景图时候与清除浮动样式冲突
- JAVA01
- hessian协议从rpc服务获取inputStream流下载文件的方式,出现异常 java.io.IOException: stream is closed
- 【MyBatis】一个简单的xml配置文件;