Skip to content

Commit bb8748c

Browse files
committed
* Added setting for standby cache
* Added more functions behind some settings * Minor design changes
1 parent 90ccef8 commit bb8748c

File tree

7 files changed

+63
-13
lines changed

7 files changed

+63
-13
lines changed

MemPlus/App.config

+4-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
<setting name="BorderThickness" serializeAs="String">
2020
<value>3</value>
2121
</setting>
22-
<setting name="FileSystemCache" serializeAs="String">
22+
<setting name="StandByCache" serializeAs="String">
2323
<value>True</value>
2424
</setting>
2525
<setting name="DisableOnInactive" serializeAs="String">
@@ -37,6 +37,9 @@
3737
<setting name="RamMonitorInterval" serializeAs="String">
3838
<value>1000</value>
3939
</setting>
40+
<setting name="FileSystemCache" serializeAs="String">
41+
<value>True</value>
42+
</setting>
4043
</MemPlus.Properties.Settings>
4144
</userSettings>
4245
</configuration>

MemPlus/Classes/RAM/RamController.cs

+17-3
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ internal sealed class RamController
7171
/// Property displaying whether the RAM monitor is enabled or not
7272
/// </summary>
7373
internal bool RamMonitorEnabled { get; private set; }
74+
/// <summary>
75+
/// Property displaying whether the FileSystem cache should be cleared or not during memory optimisation
76+
/// </summary>
77+
internal bool ClearFileSystemCache { get; set; }
78+
/// <summary>
79+
/// Property displaying whether the standby cache should be cleared or not during memory optimisation
80+
/// </summary>
81+
internal bool ClearStandbyCache { get; set; }
82+
7483
#endregion
7584

7685
/// <summary>
@@ -99,6 +108,8 @@ internal RamController(Dispatcher dispatcher, SfCircularGauge gauge, Label lblTo
99108
_lblAvailable = lblAvailable ?? throw new ArgumentNullException(nameof(lblAvailable));
100109

101110
_ramOptimizer = new RamOptimizer(_logController);
111+
ClearStandbyCache = true;
112+
ClearFileSystemCache = true;
102113

103114
_ramTimer = new Timer();
104115
_ramTimer.Elapsed += OnTimedEvent;
@@ -176,10 +187,9 @@ private void OnTimedEvent(object source, ElapsedEventArgs e)
176187
/// <summary>
177188
/// Clear all non-essential RAM
178189
/// </summary>
179-
/// <param name="filesystemcache">A boolean to indicate whether or not to clear the FileSystem cache</param>
180190
/// <param name="exceptionsList">A list of processes that should be excluded from memory optimisation</param>
181191
/// <returns></returns>
182-
internal async Task ClearMemory(bool filesystemcache, List<string> exceptionsList)
192+
internal async Task ClearMemory(List<string> exceptionsList)
183193
{
184194
_logController.AddLog(new ApplicationLog("Clearing RAM memory"));
185195

@@ -190,7 +200,11 @@ await Task.Run(async () =>
190200
double oldUsage = RamUsage;
191201

192202
_ramOptimizer.EmptyWorkingSetFunction(exceptionsList);
193-
_ramOptimizer.ClearFileSystemCache(filesystemcache);
203+
204+
if (ClearFileSystemCache)
205+
{
206+
_ramOptimizer.ClearFileSystemCache(ClearStandbyCache);
207+
}
194208

195209
await Task.Delay(10000);
196210

MemPlus/Properties/Settings.Designer.cs

+15-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MemPlus/Properties/Settings.settings

+4-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
<Setting Name="BorderThickness" Type="System.Int32" Scope="User">
1212
<Value Profile="(Default)">3</Value>
1313
</Setting>
14-
<Setting Name="FileSystemCache" Type="System.Boolean" Scope="User">
14+
<Setting Name="StandByCache" Type="System.Boolean" Scope="User">
1515
<Value Profile="(Default)">True</Value>
1616
</Setting>
1717
<Setting Name="ProcessExceptions" Type="System.Collections.Generic.List&lt;System.String&gt;" Scope="User">
@@ -32,5 +32,8 @@
3232
<Setting Name="RamMonitorInterval" Type="System.Int32" Scope="User">
3333
<Value Profile="(Default)">1000</Value>
3434
</Setting>
35+
<Setting Name="FileSystemCache" Type="System.Boolean" Scope="User">
36+
<Value Profile="(Default)">True</Value>
37+
</Setting>
3538
</Settings>
3639
</SettingsFile>

MemPlus/Windows/MainWindow.xaml.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ internal void LoadProperties()
4444
MniDisableInactive.IsChecked = Properties.Settings.Default.DisableOnInactive;
4545
MniOnTop.IsChecked = Properties.Settings.Default.Topmost;
4646
MniRamMonitor.IsChecked = Properties.Settings.Default.RamMonitor;
47+
48+
_ramController.ClearFileSystemCache = Properties.Settings.Default.FileSystemCache;
49+
_ramController.ClearStandbyCache = Properties.Settings.Default.StandByCache;
4750
_ramController.SetTimerInterval(Properties.Settings.Default.RamMonitorInterval);
4851

4952
if (Properties.Settings.Default.RamMonitor)
@@ -96,7 +99,7 @@ private async void BtnClearMemory_OnClick(object sender, RoutedEventArgs e)
9699
{
97100
BtnClearMemory.IsEnabled = false;
98101

99-
await _ramController.ClearMemory(Properties.Settings.Default.FileSystemCache, Properties.Settings.Default.ProcessExceptions);
102+
await _ramController.ClearMemory(Properties.Settings.Default.ProcessExceptions);
100103
double ramSavings = _ramController.RamSavings / 1024 / 1024;
101104
if (ramSavings < 0)
102105
{

MemPlus/Windows/SettingsWindow.xaml

+12-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<RowDefinition Height="Auto"></RowDefinition>
2929
</Grid.RowDefinitions>
3030

31-
<GroupBox Grid.Row="0" Header="General" MinWidth="250" Margin="3">
31+
<GroupBox Grid.Row="0" Header="MemPlus" MinWidth="250" Margin="3">
3232
<Grid>
3333
<Grid.RowDefinitions>
3434
<RowDefinition Height="Auto"></RowDefinition>
@@ -73,14 +73,16 @@
7373
Image="../Resources/Images/ram_tab.png"
7474
ImageWidth="16" ImageHeight="16">
7575

76-
<Grid x:Name="ChbStandByCache" HorizontalAlignment="Center" VerticalAlignment="Center">
76+
<Grid HorizontalAlignment="Center" VerticalAlignment="Center">
7777
<Grid.RowDefinitions>
78+
<RowDefinition Height="Auto"></RowDefinition>
7879
<RowDefinition Height="Auto"></RowDefinition>
7980
<RowDefinition></RowDefinition>
8081
</Grid.RowDefinitions>
8182

82-
<CheckBox Content="Clear standby cache" Margin="3" />
83-
<GroupBox Grid.Row="1" Header="Exclusions" MinWidth="250" Margin="3">
83+
<CheckBox Grid.Row="0" x:Name="ChbFileSystemCache" Content="Clear FileSystem cache" Margin="3" />
84+
<CheckBox Grid.Row="1" x:Name="ChbStandByCache" Content="Clear standby cache" Margin="3" />
85+
<GroupBox Grid.Row="2" Header="Exclusions" MinWidth="250" Margin="3">
8486
<Grid>
8587
<Grid.RowDefinitions>
8688
<RowDefinition></RowDefinition>
@@ -89,6 +91,12 @@
8991
<ListView Margin="3" Height="100">
9092
<ListView.ContextMenu>
9193
<ContextMenu>
94+
<MenuItem Header="Copy">
95+
<MenuItem.Icon>
96+
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/log.png" ></Image>
97+
</MenuItem.Icon>
98+
</MenuItem>
99+
<Separator />
92100
<MenuItem Header="Delete">
93101
<MenuItem.Icon>
94102
<Image Width="16" Height="16" Source="/MemPlus;component/Resources/Images/delete.png" ></Image>

MemPlus/Windows/SettingsWindow.xaml.cs

+7
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ private void LoadProperties()
6060
ChbDisableInactive.IsChecked = Properties.Settings.Default.DisableOnInactive;
6161
ItbRamMonitorTimeout.Value = Properties.Settings.Default.RamMonitorInterval;
6262

63+
ChbFileSystemCache.IsChecked = Properties.Settings.Default.FileSystemCache;
64+
ChbStandByCache.IsChecked = Properties.Settings.Default.StandByCache;
65+
6366
_logController.AddLog(new ApplicationLog("Done loading SettingsWindow properties"));
6467
}
6568

@@ -75,6 +78,10 @@ private void SaveProperties()
7578
if (ChbDisableInactive.IsChecked != null) Properties.Settings.Default.DisableOnInactive = ChbDisableInactive.IsChecked.Value;
7679
if (ItbRamMonitorTimeout.Value != null) Properties.Settings.Default.RamMonitorInterval = (int) ItbRamMonitorTimeout.Value;
7780

81+
//RAM Optimizer
82+
if (ChbFileSystemCache.IsChecked != null) Properties.Settings.Default.FileSystemCache = ChbFileSystemCache.IsChecked.Value;
83+
if (ChbStandByCache.IsChecked != null) Properties.Settings.Default.StandByCache = ChbStandByCache.IsChecked.Value;
84+
7885
Properties.Settings.Default.Save();
7986

8087
_mainWindow.ChangeVisualStyle();

0 commit comments

Comments
 (0)