今天看了clr via c# 知道了在debug和release下垃圾回收针对方法中局部引用变量jit的操作是不一样的,留此文纪念。

以下代码在debug与release下运行结果不一样. 参见clr via c# 3.0 P528
using System.Threading;

namespace GCtest
{

    public static class Program
    {
        public static void Main()
        {
            // Create a Timer object that knows to call our TimerCallback
            // method once every 2000 milliseconds.
            Timer t = new Timer(TimerCallback, null, 0, 2000);
            // Wait for the user to hit <Enter>
            Console.ReadLine();
        }
        private static void TimerCallback(Object o)
        {
            // Display the date/time when this method got called.
            Console.WriteLine("In TimerCallback: " + DateTime.Now);
            // Force a garbage collection to occur for this demo.
            GC.Collect();
        }
    }
}
原文地址:https://www.cnblogs.com/jiangzhen/p/1888421.html