|
- using System;
- using System.Collections.Generic;
- using System.Diagnostics;
- using System.Runtime.InteropServices;
- using System.Text;
-
- namespace Shadowsocks.Util
- {
- public class Util
- {
- public static void ReleaseMemory()
- {
- // release any unused pages
- // making the numbers look good in task manager
- // this is totally nonsense in programming
- // but good for those users who care
- // making them happier with their everyday life
- // which is part of user experience
- GC.Collect(GC.MaxGeneration);
- GC.WaitForPendingFinalizers();
- SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle,
- (UIntPtr)0xFFFFFFFF, (UIntPtr)0xFFFFFFFF);
- }
-
- [DllImport("kernel32.dll")]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool SetProcessWorkingSetSize(IntPtr process,
- UIntPtr minimumWorkingSetSize, UIntPtr maximumWorkingSetSize);
- }
- }
|