static void Main(string[] args) { Console.WriteLine("Allocating some stuff with allocation logging off"); for (int i = 0; i < 10000; i++) { Demo3 demo3 = new Demo3(); } Console.WriteLine("Turning allocation logging on"); // Turn allocation logging ON CLRProfilerControl.AllocationLoggingActive = true; ht = new Hashtable(); for (int i = 0; i < 1000; i++) { ht[i] = string.Format("Value {0}", i); } // Turn allocation logging OFF CLRProfilerControl.AllocationLoggingActive = false; }