SetProcessWorkingSetSize減少內存佔用?啥也不是

結論:別用這個函數,他會把內存寫不下的寫到硬盤的虛擬內存中去(注:硬盤中的虛擬內存默認在系統盤裏)
貼一段 博客園名稱pdfw的代碼

點擊查看代碼

[System.Runtime.InteropServices.DllImportAttribute("kernel32.dll", EntryPoint = "SetProcessWorkingSetSize", ExactSpelling = true, CharSet =System.Runtime.InteropServices.CharSet.Ansi, SetLastError = true)]
private static extern int SetProcessWorkingSetSize(IntPtr process, int minimumWorkingSetSize, int maximumWorkingSetSize);
public void Dispose(){   
 GC.Collect(); 
 GC.SuppressFinalize(this); 
 if (Environment.OSVersion.Platform == PlatformID.Win32NT)  
  {        
   SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);  
  }}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章