class StaticTest{
public static SomeClass statVar = new SomeClass();
}
After this if we access StaticTest.statVar and assign some new objects at random times, then when all these objects will get garbage collected? Answer: In normal garbage collection time.
But what if this statVar has references to some instance variables(objects)?
Not clear?
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?
I would be very happy to discuss on this.