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>
        /// Event that will be called when the timer interval was reached
        /// </summary>
        /// <param name="source">The calling object</param>
        /// <param name="e">The ElapsedEventArgs</param>
        private void OnTimedEvent(object source, ElapsedEventArgs e)
        {
            _logController.AddLog(new ApplicationLog("RAM monitor timer has been called"));

            UpdateRamUsage();
            UpdateGuiStatisticsEvent.Invoke();

            _logController.AddLog(new ApplicationLog("Finished RAM monitor timer"));
        }
Exemplo n.º 3
0
        /// <summary>
        /// Enable RAM usage monitoring
        /// </summary>
        internal void EnableMonitor()
        {
            if (_ramTimer.Enabled)
            {
                return;
            }

            _ramTimer.Enabled = true;
            RamMonitorEnabled = true;

            UpdateRamUsage();
            UpdateGuiStatisticsEvent.Invoke();

            _logController.AddLog(new ApplicationLog("The RAM monitor has been enabled"));
        }
Exemplo n.º 4
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.º 5
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"));
        }