private static long GetNumBytesUsed(int numInts) { // force garbage collection GC.Collect(); var begin = MemoryUtilities.NumBytesUsed(true); var ints = new int[numInts]; ints[0] = 123; var end = MemoryUtilities.NumBytesUsed(true); // force the array to be in memory until we have our measurements Assert.Equal(123, ints[0]); return(end - begin); }