public static void Main(string[] p_args) { long iterations = 200000000; GCSmall ns = new GCSmall(); Stopwatch sw = new Stopwatch(); sw.Start(); for (long i = 0; i < iterations; i++) { ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); } if (ns == null) { Console.WriteLine("Shouldn't get here"); } GC.KeepAlive(ns); sw.Stop(); Console.WriteLine("took {0} ms in total", sw.ElapsedMilliseconds); }
public static void Main(string[] p_args) { long iterations = 200; GCSmall ns = new GCSmall(); for (long i = 0; i < iterations; i++) { ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); ns = new GCSmall(); } if (ns == null) { Console.WriteLine("Shouldn't get here"); } GC.KeepAlive(ns); }