Пример #1
0
        public static void Main(string[] args)
        {
            for (int i = 0; i < 10000; i++)
            {
                Garbage[] garbage = new Garbage[10000];
                garbage[i] = new Garbage();
            }

            Console.WriteLine("Memory used before collection       :" + GC.GetTotalMemory(false));

            //Garbage Collector
            GC.Collect();
            Console.WriteLine("Memory used after garbage collection:" + GC.GetTotalMemory(false));
        }
Пример #2
0
        public static void Main(string[] args)
        {
            for (int i = 0; i < 10000; i++) {

                Garbage[] garbage = new Garbage[10000];
                garbage[i]=new Garbage();

            }

            Console.WriteLine ("Memory used before collection       :"+GC.GetTotalMemory(false));

            //Garbage Collector
            GC.Collect();
            Console.WriteLine ("Memory used after garbage collection:"+GC.GetTotalMemory(false));
        }