[DllImport("psapi.dll")] private static extern int EmptyWorkingSet(int hProcess); public void HandleSetGC() { GC.Collect(); GC.WaitForPendingFinalizers(); EmptyWorkingSet(Process.GetCurrentProcess().Handle.ToInt32()); }