Do static member variables ever get garbage collected?
For example, let's use the following class.
public class HasStatic {
private static List<string> shared = new List<string>();
}
And supposed that it's used like this:
//Startup
{
HasStatic a = new HasStatic();
HasStatic b = new HasStatic();
HasStatic c = new HasStatic();
HasStatic d = new HasStatic();
//Something
}
//Other code
//Things deep GC somewhere in here
HasStatic e = new HasStatic();
When a
, b
, c
, and d
are garbage collected does the static member shared
get collected as well? Could e
possibly get a new instance of shared
?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…