public static int Main() { Console.WriteLine("Beginning phase 1"); GCUtil.AllocWithGaps(); Console.WriteLine("phase 1 complete"); // losing all live references to the unpinned byte arrays // this will fragment the heap with ~50 byte holes GCUtil.FreeNonPins(); GC.Collect(); GC.WaitForPendingFinalizers(); GC.Collect(); Console.WriteLine("Beginning phase 2"); bList = new List <byte[]>(); for (int i = 0; i < 1024 * 1024; i++) { byte[] unpinned = new byte[50]; bList.Add(unpinned); } Console.WriteLine("phase 2 complete"); GC.KeepAlive(gchList); GC.KeepAlive(bList); return(100); }
public static int Main() { Console.WriteLine("First Alloc"); GCUtil.Alloc(1024 * 1024 * 4, 30); GCUtil.FreeNonPins(); GC.Collect(); Console.WriteLine("Second Alloc"); GCUtil.Alloc(1024 * 1024 * 4, 50); GCUtil.FreeNonPins(); GC.Collect(); GCUtil.FreePins(); Console.WriteLine("Test passed"); return(100); }
public static int Main() { TestFramework.LogInformation("First Alloc"); GCUtil.Alloc(1024 * 1024, 50); GCUtil.FreeNonPins(); GC.Collect(); TestFramework.LogInformation("Second Alloc"); GCUtil.Alloc(1024 * 1024, 50); GCUtil.FreeNonPins(); GC.Collect(); GCUtil.FreePins(); TestFramework.LogInformation("Test passed"); return(100); }