结论:别用这个函数,他会把内存写不下的写到硬盘的虚拟内存中去(注:硬盘中的虚拟内存默认在系统盘里)
贴一段 博客园名称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);
}}