Esempio n. 1
0
 public static void ReleaseMemory(bool removePages)
 {
     // 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();
     if (removePages)
     {
         // as some users have pointed out
         // removing pages from working set will cause some IO
         // which lowered user experience for another group of users
         //
         // so we do 2 more things here to satisfy them:
         // 1. only remove pages once when configuration is changed
         // 2. add more comments here to tell users that calling
         //    this function will not be more frequent than
         //    IM apps writing chat logs, or web browsers writing cache files
         //    if they're so concerned about their disk, they should
         //    uninstall all IM apps and web browsers
         //
         // please open an issue if you're worried about anything else in your computer
         // no matter it's GPU performance, monitor contrast, audio fidelity
         // or anything else in the task manager
         // we'll do as much as we can to help you
         //
         // just kidding
         WINAPI.ReleasePages(Process.GetCurrentProcess().Handle);
     }
 }