C#程序节省内存

 1 using System.Runtime.InteropServices;
 2 using System.Diagnostics;
 3 
 4 [DllImport("kernel32.dll")] 
 5 private static extern bool SetProcessWorkingSetSize(IntPtr process,int minSize,
 6                             int maxSize);
 7                                         
 8 private static void FlushMemory()
 9 {
10  GC.Collect();     
11  GC.WaitForPendingFinalizers(); 
12  if(Environment.OSVersion.Platform == PlatformID.Win32NT)
13     SetProcessWorkingSetSize( Process.GetCurrentProcess().Handle , -1-1);
14 }
posted @ 2009-05-21 11:59  指尖舞者  阅读(400)  评论(0编辑  收藏  举报