mirror of
https://github.com/snltty/linker.git
synced 2025-10-14 13:23:45 +08:00
28 lines
759 B
C#
28 lines
759 B
C#
using System;
|
|
using System.Diagnostics;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace linker.libs
|
|
{
|
|
public static class GCHelper
|
|
{
|
|
[DllImport("kernel32.dll")]
|
|
public static extern bool SetProcessWorkingSetSize(IntPtr proc, int min, int max);
|
|
public static void FlushMemory()
|
|
{
|
|
GC.Collect();
|
|
GC.SuppressFinalize(true);
|
|
GC.WaitForPendingFinalizers();
|
|
if (Environment.OSVersion.Platform == PlatformID.Win32NT)
|
|
{
|
|
SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
|
|
}
|
|
}
|
|
public static void Gc(object obj)
|
|
{
|
|
GC.Collect();
|
|
GC.SuppressFinalize(obj);
|
|
}
|
|
}
|
|
}
|