title: Garbage collection of objects referenced by static variables
body: <pre><code>class StaticTest{
  
  public static SomeClass statVar = new SomeClass();
  
  }
  </code></pre>
  
  <p>After this if we access <code>StaticTest.statVar</code> and assign some new objects at random times, then when all these objects will get garbage collected? Answer: In normal garbage collection time.</p>
  
  <p>But what if this <code>statVar</code> has references to some instance variables(objects)? </p>
  
  <p>Not clear?</p>
  
  <p>Ok, static variables life time is until the class unloaded. In web applications we are initializing many things in static context. Incase if we are providing some object references to this static context but we are not releasing them, then how it gets garbage collected?</p>
  
  <p>I would be very happy to discuss on this.</p>