BelhardTraining.FinalizerDemo.Program.Main C# (CSharp) Метод

Main() статический приватный Метод

static private Main ( ) : void
Результат void
        static void Main()
        {
            Process proc = Process.GetCurrentProcess();
            long initialMemory = proc.PrivateMemorySize64;
            Console.WriteLine(initialMemory.ToString("N0"));
            long threshold = initialMemory*100;
            for (;;)
            {
                for (int i = 0; i < 100; i++)
                {
                    var smth = new Something();
                    smth.DoSomething();
                    Console.Write("+");
                    //Thread.Sleep(20);
                }

                Console.Write(" ");

                proc.Refresh();
                long currentMemory = proc.PrivateMemorySize64;
                Console.Write("{0:N0} ", currentMemory);
                if (currentMemory > initialMemory && currentMemory - initialMemory > threshold)
                {
                    GC.Collect();
                    GC.WaitForPendingFinalizers();
                    GC.Collect();
                    Console.Write("!");
                }
                Console.WriteLine();
                Thread.Sleep(500);
            }
        }
Program