Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [DllImport("kernel32.dll", EntryPoint="SetProcessWorkingSetSize", ExactSpelling=true, CharSet=CharSet.Ansi, SetLastError=true)]
- private static extern int SetProcessWorkingSetSize(IntPtr process, int minimumWorkingSetSize, int maximumWorkingSetSize);
- /// <summary>
- /// Reduce the working set size off the application to a minimum.
- /// </summary>
- public void ReduceWorkingSet()
- {
- GC.Collect();
- GC.WaitForPendingFinalizers();
- try
- {
- if (Environment.OSVersion.Platform == PlatformID.Win32NT)
- {
- String name = System.Diagnostics.Process.GetCurrentProcess().ProcessName;
- SetProcessWorkingSetSize(System.Diagnostics.Process.GetCurrentProcess().Handle, -1, -1);
- }
- }
- catch (Exception e)
- {
- Console.Out.WriteLine(e.Message);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment