当前位置:首页 > 服务端 > TOMCAT SHUTDOWN MEMORY LEAK

TOMCAT SHUTDOWN MEMORY LEAK

TOMCAT SHUTDOWN MEMORY LEAK

Environement

JDK 1.6.0.45

Tomcat 7.0.70

JDBC ojdbc6 (11.2.0.1)

 

Symptom

When shutdown Tomcat, memory leak messages occur.

The web application [/MyWeb] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
The web application [/MyWeb] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1a3da69]) and a value of type [java.lang.Class] (value [class oracle.sql.AnyDataFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
The web application [/MyWeb] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@58431c]) and a value of type [java.lang.Class] (value [class oracle.sql.TypeDescriptorFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 

These three objects cannot be garbage collected, so the memory cannot be freed up, and it may finally cause out of memory exception.

 

Solution 1

Move ojdbc6.jar to Tomcat/lib folder (remove from WEB-INF/lib)

Solution 2

Using ojdbc14.jar (10.2.0.4) and keep it in WEB-INF/lib. No TheadLocal problem. Although JDBC memory leak message still occurs, it will not cause out of memory exception even if we reload the app many times.

 

Write a ContextListener to deregister JDBC driver only solve JDBC memory leak, but useless for ThreadLocal problem. ThreadLocal memory leak will cause out of memory problem.

 

Reference

 

Advertisements

TOMCAT SHUTDOWN MEMORY LEAK

Environement

JDK 1.6.0.45

Tomcat 7.0.70

JDBC ojdbc6 (11.2.0.1)

 

Symptom

When shutdown Tomcat, memory leak messages occur.

The web application [/MyWeb] registered the JDBC driver [oracle.jdbc.OracleDriver] but failed to unregister it when the web application was stopped. To prevent a memory leak, the JDBC Driver has been forcibly unregistered.
The web application [/MyWeb] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@1a3da69]) and a value of type [java.lang.Class] (value [class oracle.sql.AnyDataFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak.
The web application [/MyWeb] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@58431c]) and a value of type [java.lang.Class] (value [class oracle.sql.TypeDescriptorFactory]) but failed to remove it when the web application was stopped. Threads are going to be renewed over time to try and avoid a probable memory leak. 

These three objects cannot be garbage collected, so the memory cannot be freed up, and it may finally cause out of memory exception.

 

Solution 1

Move ojdbc6.jar to Tomcat/lib folder (remove from WEB-INF/lib)

Solution 2

Using ojdbc14.jar (10.2.0.4) and keep it in WEB-INF/lib. No TheadLocal problem. Although JDBC memory leak message still occurs, it will not cause out of memory exception even if we reload the app many times.

 

Write a ContextListener to deregister JDBC driver only solve JDBC memory leak, but useless for ThreadLocal problem. ThreadLocal memory leak will cause out of memory problem.

 

Reference

 

Advertisements
REPORT THIS AD

 

http://javarevisited.blogspot.tw/2013/01/threadlocal-memory-leak-in-java-web.html

http://java.jiderhamn.se/2012/01/29/classloader-leaks-iv-threadlocal-dangers-and-why-threadglobal-may-have-been-a-more-appropriate-name/

https://blog.edgewater.com/2013/01/03/hunting-down-an-apache-permgen-issue/

http://stackoverflow.com/questions/3320400/to-prevent-a-memory-leak-the-jdbc-driver-has-been-forcibly-unregistered

REPORT THIS AD

 

http://javarevisited.blogspot.tw/2013/01/threadlocal-memory-leak-in-java-web.html

http://java.jiderhamn.se/2012/01/29/classloader-leaks-iv-threadlocal-dangers-and-why-threadglobal-may-have-been-a-more-appropriate-name/

https://blog.edgewater.com/2013/01/03/hunting-down-an-apache-permgen-issue/

http://stackoverflow.com/questions/3320400/to-prevent-a-memory-leak-the-jdbc-driver-has-been-forcibly-unregistered

 

作者:Ben赵烨
来源链接:https://www.cnblogs.com/ben98/p/15740193.html

版权声明:
1、Java侠(https://www.javaxia.com)以学习交流为目的,由作者投稿、网友推荐和小编整理收藏优秀的IT技术及相关内容,包括但不限于文字、图片、音频、视频、软件、程序等,其均来自互联网,本站不享有版权,版权归原作者所有。

2、本站提供的内容仅用于个人学习、研究或欣赏,以及其他非商业性或非盈利性用途,但同时应遵守著作权法及其他相关法律的规定,不得侵犯相关权利人及本网站的合法权利。
3、本网站内容原作者如不愿意在本网站刊登内容,请及时通知本站(javaclubcn@163.com),我们将第一时间核实后及时予以删除。





本文链接:https://www.javaxia.com/server/125475.html

标签: out of memory
分享给朋友: