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);  
  }}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章