Created
October 19, 2016 15:30
-
-
Save catwarrior/9f90e116206a7aa117daf7b34f66da0a to your computer and use it in GitHub Desktop.
// release any unused pages , making the numbers look good in task manager
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/// | |
[DllImport("kernel32.dll")] | |
[return: MarshalAs(UnmanagedType.Bool)] | |
private static extern bool SetProcessWorkingSetSize(IntPtr process, | |
UIntPtr minimumWorkingSetSize, UIntPtr maximumWorkingSetSize); | |
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment