| Author |
tomcat leak :static class variables
|
amir taghvayi
Ranch Hand
Joined: Sep 16, 2011
Posts: 54
|
|
hi
i read this article: http://wiki.apache.org/tomcat/MemoryLeakProtection#staticClassVariables
The article was written:
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?
please help me .
|
 |
ali farozi
Greenhorn
Joined: May 23, 2012
Posts: 6
|
|
|
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.
|
 |
 |
|
|
subject: tomcat leak :static class variables
|
|
|