1. 程式人生 > >c#垃圾清除,特別有效

c#垃圾清除,特別有效

rpe environ process hand spa get finalize poi roc

1 [DllImport("kernel32.dll"),EntryPoint = "SetProcessWorkingSetSize"]
2 public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize,intMaxSize); 
3 
4 GC.Collect();
5 GC.WaitForPendingFinalizers();
6 if(Environment.OSVersion.Platform == PlatformID,Win32NT)
7 {
8     SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle,-1
,-1); 9 }

c#垃圾清除,特別有效