Tomcat 6 中的 sun.net.www.http.HttpClient 内存泄漏
我使用的是Tomcat 6.0.18。取消部署我的应用程序后,HttpClient 似乎持有对 WebappClassLoader 的引用,因此导致内存泄漏。
经过一番调查,我在 Tomcat 7.0.6 中找到了解决方案,JreMemoryLeakPreventionListener具有 keepAliveProtection 属性。但这种方法不适用于Tomcats 6(我定制了JreMemoryLeakPreventionListener,以添加对此属性的支持)。
有人有解决 Tomcat 6 中这个泄漏的解决方案吗? 谢谢!
I'm using Tomcat 6.0.18. After undeployemnt of my app, HttpClient appears to be holding a reference to WebappClassLoader, hence causing the memory leak.
After some investigation, I've found solution in Tomcat 7.0.6, JreMemoryLeakPreventionListener with keepAliveProtection attribute. But this approach is not working with Tomcats 6 (I've customized JreMemoryLeakPreventionListener, in order to add support for this attribute).
Does anybody have a solution how to fix this leak in Tomcat 6?
Thanx!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我已经找到了内存泄漏的解决方案。
必须实现 ServletContextListener,如下所示:
并且,当然,要在 web.xml 中注册监听器:
I've found the solution for memory leak.
One must make implementation of ServletContextListener, as following:
and, of course, to register listener in web.xml: