본문으로 바로가기

[자바] tomcat 에서 보이는 memory leak 해결 방법

 

톰캣에서 메모리 릭 로그 없애는 방법 /


server.xml / Connector/J V5.1.31


tomcat 에서 stop 할 때 아래와 같은 error message 가 보일 때

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.


server.xml<!-- Prevent memory leaks due to use of particular java/javax APIs--> <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" classesToInitialize="com.mysql.jdbc.NonRegisteringDriver"/>
Connector/J V5.1.31ref. 2 에서는 mysql driver 의 버전 Connector/J V5.1.31 이상이면 해결된다고 한다.



v.5.1.31 만 사용하고 위의 server.xml 설정을 하지 않은 경우는 여전히 memory leak log 가 나왔다.



$TOMCAT/lib/mysql-connector-java-*.jar

ref. 3 에 따르면 Connector/J (mysql-connector-java-5.1.*.jar) 는 $TOMCAT/lib 에 있어야 한다고 한다. 여러 web app 을 실행하는 경우에는 확실히 필요할 듯 하다. single web app 인 경우는 잘 모르겠다.

개인적으로 maven 으로 mysql-connector-java 를 사용하는 상태였는데, tomcat 으로 사용하기 위해서 이녀석을 war 로 묶을 때 같이 archive 하지 않게 설정하였다.

<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.32</version> <scope>provided</scope> </dependency>

'자바' 카테고리의 다른 글

[도메인 주도 개발 시작하기]  (0) 2023.06.15
[프로그래머스] 신고 결과 받기 for JAVA  (0) 2022.02.01
ClientIFTestHandler  (0) 2017.07.21
ClientIFTest  (0) 2017.07.21
Generic  (0) 2017.06.22