Beispiel #1
0
        static void Main(string[] args)
        {
            while (true)
            {
                UnmanagedMemoryManager m = new UnmanagedMemoryManager();
                m = null;

                GC.Collect();   //GC로 의해 소멸자가 호출되어 비관리 메모리도 해제
                Console.WriteLine(Process.GetCurrentProcess().PrivateMemorySize64);
            }
        }
        static void Main(string[] args)
        {
            while (true)
            {
                /*
                 * UnmanagedMemoryManager m = new UnmanagedMemoryManager();
                 * m = null;
                 * GC.Collect();   //GC를 강제로 수행
                 */
                //using을 사용하여 수행
                using (UnmanagedMemoryManager m = new UnmanagedMemoryManager())
                {
                }

                //현재 프로세스가 사용하는 메모리 크기 출력
                Console.WriteLine(Process.GetCurrentProcess().PrivateMemorySize64);
            }
        }