// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; namespace E { public class Program { private static long MemUsed() { return GC.GetTotalMemory(true); } public static void Test(int n) where T : struct { long m1 = MemUsed(); T[] a = new T[n]; long m2 = MemUsed(); Console.WriteLine(typeof(T).Name + " : " + (m2 - m1) / n + " bytes/object"); } public static void Main(string[] args) { for(int i = 1; i <= 1000000; i *= 10) { Test(i); Test(i); Test(i); } } } }