čtvrtek 11. února 2010

Java Web Container: Hunting Redeploy Memory Leaks

Using a ThreadLocal in a web application (WAR) may simplify the development, but one must have a very deep understanding of the web container (e.g. Tomcat) internals and Java class loading to avoid memory leaks when WAR is redeployed. See

The problem might be hidden deep in any library used by the application. To check, if the redeploy memory leak occurs is simple with Eclipse Memory Analyzer (MAT). Just redeploy the WAR several times, make a heap dump (e.g. by jmap or jconsole). Then open the heap dump in MAT and click the link Duplicate Classes: List classes loaded by more than one class loader. If there are some duplicated classes, then you have a memory leak.

Tip: how to clean ThreadLocals in a servlet: http://www.dewavrin.info/?p=196

Žádné komentáře: