I have been debugging this issue using jvisiualvm and eclipse MAT. I had the below error when I was undeploying the war file. And after 10 deployments the tomcat was running out of memory
SEVERE: The web application [/mywar] created a ThreadLocal with key of type [java.lang.ThreadLocal] (value [java.lang.ThreadLocal@75af844e]) and a value of type [com.sun.xml.messaging.saaj.util.transform.EfficientStreamingTransformer] (value [com.sun.xml.messaging.saaj.util.transform.EfficientStreamingTransformer@5617593e]) 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.
After doing some research i found that this issue existed with the version 1.3 of saaj-impl
Since I use maven so i only had to update the below dependency
<dependency> <groupId>com.sun.xml.messaging.saaj</groupId> <artifactId>saaj-impl</artifactId> <version>1.3.4</version> // here I was using 1.3 before </dependency>