結論:別用這個函數,他會把內存寫不下的寫到硬盤的虛擬內存中去(注:硬盤中的虛擬內存默認在系統盤裏)
貼一段 博客園名稱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);
}}