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

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

                    double oldUsage = _ramUsageHistory[_ramUsageHistory.Count - 1].TotalUsed;

                    _ramOptimizer.EmptyWorkingSetFunction(_processExceptionList);

                    await Task.Delay(10000);

                    UpdateRamUsage();

                    double newUsage = _ramUsageHistory[_ramUsageHistory.Count - 1].TotalUsed;

                    RamSavings = oldUsage - newUsage;
                }
                catch (Exception ex)
                {
                    _logController.AddLog(new ErrorLog(ex.Message));
                }
            });

            RamClearingCompletedEvent?.Invoke();

            _logController.AddLog(new ApplicationLog("Done clearing process working sets"));
        }
示例#2
0
        /// <summary>
        /// Clear the FileSystem cache
        /// </summary>
        /// <returns>A Task object</returns>
        internal async Task ClearFileSystemCaches()
        {
            _logController.AddLog(new ApplicationLog("Clearing FileSystem cache"));

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

                    double oldUsage = _ramUsageHistory[_ramUsageHistory.Count - 1].TotalUsed;

                    _ramOptimizer.ClearFileSystemCache(ClearStandbyCache);

                    UpdateRamUsage();

                    double newUsage = _ramUsageHistory[_ramUsageHistory.Count - 1].TotalUsed;

                    RamSavings = oldUsage - newUsage;
                }
                catch (Exception ex)
                {
                    _logController.AddLog(new ErrorLog(ex.Message));
                }
            });

            RamClearingCompletedEvent?.Invoke();

            _logController.AddLog(new ApplicationLog("Done clearing FileSystem cache"));
        }
示例#3
0
        /// <summary>
        /// Fill the RAM
        /// </summary>
        /// <returns>A Task object</returns>
        internal async Task FillRamData()
        {
            _logController.AddLog(new ApplicationLog("Filling RAM"));

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

                    double oldUsage = _ramUsageHistory[_ramUsageHistory.Count - 1].TotalUsed;

                    _ramOptimizer.FillRam(_info, FillRamMaxRuns);

                    UpdateRamUsage();

                    double newUsage = _ramUsageHistory[_ramUsageHistory.Count - 1].TotalUsed;

                    RamSavings = oldUsage - newUsage;
                }
                catch (Exception ex)
                {
                    _logController.AddLog(new ErrorLog(ex.Message));
                }
            });

            RamClearingCompletedEvent?.Invoke();

            _logController.AddLog(new ApplicationLog("Done filling RAM"));
        }
示例#4
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;
            });

            RamClearingCompletedEvent.Invoke();

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

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

                    double oldUsage = _ramUsageHistory[_ramUsageHistory.Count - 1].TotalUsed;

                    if (FillRam)
                    {
                        _ramOptimizer.FillRam(_info, FillRamMaxRuns);
                    }

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

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

                    if (InvokeGarbageCollector)
                    {
                        GC.Collect();
                        GC.WaitForPendingFinalizers();
                    }

                    UpdateRamUsage();

                    double newUsage = _ramUsageHistory[_ramUsageHistory.Count - 1].TotalUsed;

                    RamSavings = oldUsage - newUsage;
                }
                catch (Exception ex)
                {
                    _logController.AddLog(new ErrorLog(ex.Message));
                }
            });

            if (ClearClipboard)
            {
                _ramOptimizer.ClearClipboard();
            }

            RamClearingCompletedEvent?.Invoke();

            _logController.AddLog(new ApplicationLog("Done clearing RAM memory"));
        }
示例#6
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();
            }

            RamClearingCompletedEvent.Invoke();

            _logController.AddLog(new ApplicationLog("Done clearing RAM memory"));
        }
示例#7
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;
            });

            RamClearingCompletedEvent.Invoke();

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