0

What is the difference between these flush memory functions ?
Which is better (Safe to work and causes no problem) ? thanks alot.

    public static void FlushMemoryFirst()
    {
        System.Diagnostics.Process prs = System.Diagnostics.Process.GetCurrentProcess();
        try { prs.MinWorkingSet = (IntPtr)(300000); }
        catch { }
    }
    public static void FlushMemorySecond()
    {
        System.Diagnostics.Process prs = System.Diagnostics.Process.GetCurrentProcess();
        try { prs.MaxWorkingSet = (IntPtr)((int)(prs.MaxWorkingSet + 1)); }
        catch { }
    }
Smart Man
  • 225
  • 1
  • 3
  • 16
  • Other than one poorly worded question on [social.msdn.microsoft.com](http://social.msdn.microsoft.com/Forums/windows/en-US/e8cc138f-ddde-47a8-9241-fb0d0732e1cc/setprocessworkingsetsize-or-processmaxworkingset?forum=winforms) (from 2005!), I don't see any reference online or in the [documentation](http://msdn.microsoft.com/en-us/library/system.diagnostics.process.minworkingset.aspx) on how this "flushes" memory. – crashmstr Oct 24 '13 at 11:36
  • I guess **[here](http://stackoverflow.com/questions/7387055/why-is-process-workingset-process-maxworkingset)** is the answer on your question. – user2771704 Oct 24 '13 at 11:42
  • @user2771704 nope, that question is related to the actual usage of the functions as documented. This question is about something that is not documented, or at least is some kind of side effect from setting the values. – crashmstr Oct 24 '13 at 11:44
  • The second is better, it won't have any effect although the truncation bug is going to hurt on a 64-bit operating system. The first one is *very* detrimental, your machine is going to be slow and unresponsive while the processes try to continue executing and their code and data needs to be swapped back into RAM. This was the kind of code used by the infamous "RAM cleaner" utilities. – Hans Passant Oct 24 '13 at 13:01
  • @ Hans Passant : Thanks for your answer , do you have any better idea or better code to handle this problem ? – Smart Man Oct 25 '13 at 12:27

0 Answers0