public static Action<Object> err = msg => Console.Error.WriteLine(msg);
public class Test: IDisposable
public string Name { get; set; }
public int[] arr = new int[100000];
public Test(string n) { Name = n; err("ctor " + Name); }
public void Dispose() { err("dispose "+ Name); }
Test x1 = new Test("T1");
Test x2 = new Test("T2");
Test x3 = new Test("T3");
Test x4 = new Test("T4");
Test x5 = new Test("T5");
Test x6 = new Test("T6");
public static void Main(string[] args)
err(GC.GetTotalAllocatedBytes(true));
err("After T(), before gc(): " + GC.GetTotalAllocatedBytes(true));
GC.Collect(2, GCCollectionMode.Forced, true, true);
GC.WaitForPendingFinalizers();
err("After T(), after gc(): " + GC.GetTotalAllocatedBytes(true));
Test? x1 = new Test("main1");
Test x2 = new Test("main2");
Test x3 = new Test("main3");
Test x4 = new Test("main4");
Test x5 = new Test("main5");
Test x6 = new Test("main6");
err("After main alloc(), before gc(): " + GC.GetTotalAllocatedBytes(true));
GC.Collect(2, GCCollectionMode.Forced, true, true);
GC.WaitForPendingFinalizers();
err("After main alloc, after gc(): " + GC.GetTotalAllocatedBytes(true));
Console.WriteLine("FINISHED");