Пример #1
0
        void TickIdleTimer(object sender, EventArgs e)
        {
            this.m_idleCount++;

            if (m_idleCount > 10)
            {
                if (this.m_usedEmptyWorkingSetCheck)
                {
                    return;
                }
                Win32FunctionHelper.EmptyWorkingSet();
                m_usedEmptyWorkingSetCheck = true;
            }
            if (m_idleCount > 5)
            {
                if (m_usedRecuceMemoryCheck)
                {
                    return;
                }
                Win32FunctionHelper.ReduceMemory();
                m_usedRecuceMemoryCheck = true;
            }
            else if (m_firstReduceMemoryCheck == false)
            {
                Win32FunctionHelper.ReduceMemoryAtFirstTime();
                m_firstReduceMemoryCheck = true;
            }
        }
Пример #2
0
 public static void EmptyWorkingSet()
 {
     GC.Collect();
     GC.WaitForPendingFinalizers();
     if (Environment.OSVersion.Platform == PlatformID.Win32NT)
     {
         IntPtr handle = System.Diagnostics.Process.GetCurrentProcess().Handle;
         Win32FunctionHelper.EmptyWorkingSet(handle);
     }
 }