Exemplo n.º 1
0
        /// <summary>
        /// Clear the working set of all processes, excluding the exclusion list
        /// </summary>
        /// <returns>A Task</returns>
        internal async Task ClearWorkingSets()
        {
            _logController.AddLog(new ApplicationLog("Clearing process working sets"));

            await Task.Run(async() =>
            {
                UpdateRamUsage();

                double oldUsage = RamUsage;

                _ramOptimizer.EmptyWorkingSetFunction(_processExceptionList);

                await Task.Delay(10000);

                UpdateRamUsage();
                UpdateGuiStatisticsEvent.Invoke();

                double newUsage = RamUsage;

                RamSavings = oldUsage - newUsage;
            });

            RamClearingCompletedEvcent.Invoke();

            _logController.AddLog(new ApplicationLog("Done clearing process working sets"));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Clear all non-essential RAM
        /// </summary>
        /// <returns>A Task</returns>
        internal async Task ClearMemory()
        {
            _lastAutoOptimizeTime = DateTime.Now;
            _logController.AddLog(new ApplicationLog("Clearing RAM memory"));

            await Task.Run(async() =>
            {
                UpdateRamUsage();

                double oldUsage = RamUsage;

                if (EmptyWorkingSets)
                {
                    _ramOptimizer.EmptyWorkingSetFunction(_processExceptionList);
                    await Task.Delay(10000);
                }

                if (ClearFileSystemCache)
                {
                    _ramOptimizer.ClearFileSystemCache(ClearStandbyCache);
                }

                GC.Collect();
                GC.WaitForPendingFinalizers();

                UpdateRamUsage();
                UpdateGuiStatisticsEvent.Invoke();

                double newUsage = RamUsage;

                RamSavings = oldUsage - newUsage;
            });

            if (ClearClipboard)
            {
                Clipboard.Clear();
            }

            RamClearingCompletedEvcent.Invoke();

            _logController.AddLog(new ApplicationLog("Done clearing RAM memory"));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clear the FileSystem cache
        /// </summary>
        /// <returns>A Task</returns>
        internal async Task ClearFileSystemCaches()
        {
            _logController.AddLog(new ApplicationLog("Clearing FileSystem cache"));

            await Task.Run(() =>
            {
                UpdateRamUsage();

                double oldUsage = RamUsage;

                _ramOptimizer.ClearFileSystemCache(ClearStandbyCache);

                UpdateRamUsage();
                UpdateGuiStatisticsEvent.Invoke();

                double newUsage = RamUsage;

                RamSavings = oldUsage - newUsage;
            });

            RamClearingCompletedEvcent.Invoke();

            _logController.AddLog(new ApplicationLog("Done clearing FileSystem cache"));
        }