Answer to this poser
I wasn’t sure the answer to this question was observable, so I wrote a short program:
Console.WriteLine(“Early Cleaned Up”);
public static void Main()
Early e = new Early();
The output from this is
Early Cleaned Up
In other words, there is no guarantee that a local variable will remain live until the end of a scope if it isn’t used. The runtime is free to analyze the code that it has and determine what there are no further usages of a variable beyond a certain point, and therefore not keep that variable live beyond that point (ie not treat it as a root for the purposes of GC).