When an app is stopped, Tomcat (even before 6.0.24) nullifies the value of all static class variables of classes loaded by the WebAppClassLoader. In some cases, it may fix a classloader leak (for example because of a custom ThreadLocal class, see above), but even if we still have a leak, it may decrease the amount of memory lost:
Imagine a class with the following variable :
private final static byte BUFFER = new byte[1024*1024]; //1MB buffer
Normally, the 1MB buffer should be freed when the app is stopped, but only if the classloader itself can be garbage-collected. Since there are still possibilities to have a leak of the classloader, clearing the BUFFER variable allows to recover 1MB of memory.
We do not use the staticClassVariables ?
What can be used instead of staticClassVariables?
The workaround described in the article was created to deal with the unique problem of reloadable classloaders and static class variables. If you are using regular, non-static variables then the 'porblem' doesnt apply to you, as the regular garbage collection mechanism will handle those variables just fine.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com