C# 强制GC垃圾回收
生活随笔
收集整理的這篇文章主要介紹了
C# 强制GC垃圾回收
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
在需要調用垃圾回收的地方調用ClearMemory()
public static void ClearMemory()
{
GC.Collect();
GC.WaitForPendingFinalizers();
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
}
}
[DllImport("kernel32.dll")]
public static extern int SetProcessWorkingSetSize(IntPtr process, int minSize, int maxSize);
總結
以上是生活随笔為你收集整理的C# 强制GC垃圾回收的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 802.11X用户身份验证
- 下一篇: 子模块到顶层模块——例化与调用