[DllImport("kernel32.dll")]
private static extern bool SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
form-closed时调用以下操作
GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
}
转载于:https://www.cnblogs.com/qiantao/p/9849882.html
本文介绍了一种在C#中进行内存回收的最佳实践方法,包括使用GC.Collect()进行垃圾回收,通过GC.WaitForPendingFinalizers()等待所有挂起的终结器完成,以及在Windows NT平台上使用SetProcessWorkingSetSize()来进一步降低进程的工作集大小。
1414

被折叠的 条评论
为什么被折叠?



