This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

tomcat leak :static class variables

 
amir taghvayi
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic