关闭tomcat时提示memory leak警告解决办法

原文地址:http://blog.sina.com.cn/s/blog_81b86edf01014nrq.html


当我们关闭tomcat 或者redeploy project时, 仔细看的话,会有一些error跳出来。 这些是一些memory leak的问题,自tomcat 6.0.24以后tomcat增加的安全检测机制。

不要忽视这些问题,它可能会造成memory leak, 就是tomcat关闭以后,还有thread在跑。。。 这是非常不安全,并会对服务器的稳定造成很大影响的,下面是一些总结,工作时候发给同事的,没翻译,有需要的话就将就着看吧。

Overall, the reason for these alarms is from tomcat 6.0.24, there is a new function called memory leak protection. Refer to http://wiki.apache.org/tomcat/MemoryLeakProtection. This is a good function to make our applications and server better. And there is some suggestion in this web page. Include 'JDBC driver registration' problem.

The tomcat version below 6.0.24 does not alarm these memory leak problems, but the problem is exist. (I’ve tried tomcat 6.0.20).  There is memory leak (java process still running) but no alarm. It’s dangerous.

For JDBC driver registration problem.

SEVERE: The web application [/xxx] 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. Pls refer to http://bugs.mysql.com/bug.php?id=62170.

This is not regard as a bug(whatever, it has been forcibly unregistered already), we can unregister the driver by extends the lifecycle listener of spring framework. Such as org.springframework.web.context.ContextLoaderListener.  Override the contextDestroyed() function to unregister the JDBC driver.


For mysql connector 其他问题

When we are using mysql connector version 5.0.5 (mysql-connector-java-5.0.5.jar):

MySql Bug 1: The web application [/xxx] appears to have started a thread named [MySQL Statement Cancellation Timer] but has failed to stop it. This is very likely to create a memory leak.

This bug was reported at version 5.1.6 and already been fixed already in the future version of MySql. Refer to http://bugs.mysql.com/bug.php?id=36565.

 

When we are using mysql connector version 5.1.22 (mysql-connector-java-5.1.22.jar):

MySql Bug 2: SEVERE: The web application [/xxx] 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.

This bug was reported at version 5.1.21 and its status is ‘IN PROGRESS’, it means it’s not fixed yet. Refer to http://bugs.mysql.com/bug.php?id=65909.

 

So I’m using the mysql connector 5.1.20 (mysql-connector-java-5.1.20.jar), everything looks good.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值