1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-08-13 10:16:59 +02:00

Add option to enable GC reload with a custom memory threshold (currently unused)

This commit is contained in:
2017-06-30 16:47:31 +02:00
parent 0ac244a3ea
commit c69b9784fc
3 changed files with 89 additions and 4 deletions

@@ -56,6 +56,9 @@ namespace TweetDuck.Configuration{
public string CustomBrowserCSS { get; set; }
public string CustomNotificationCSS { get; set; }
public bool EnableBrowserGCReload { get; set; }
public int BrowserMemoryThreshold { get; set; }
public bool IsCustomNotificationPositionSet => CustomNotificationPosition != ControlExtensions.InvisibleLocation;
public bool IsCustomNotificationSizeSet => CustomNotificationSize != Size.Empty;
@@ -132,6 +135,7 @@ namespace TweetDuck.Configuration{
NotificationEdgeDistance = 8;
NotificationDurationValue = 25;
NotificationScrollSpeed = 100;
BrowserMemoryThreshold = 350;
EnableUpdateCheck = true;
ExpandLinksOnHover = true;
SwitchAccountSelectors = true;
@@ -198,6 +202,7 @@ namespace TweetDuck.Configuration{
if (fileVersion == 10){
NotificationSize = TweetNotification.Size.Auto;
BrowserMemoryThreshold = 350;
++fileVersion;
}

@@ -24,6 +24,7 @@
/// </summary>
private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(TabSettingsAdvanced));
this.btnClearCache = new System.Windows.Forms.Button();
this.checkHardwareAcceleration = new System.Windows.Forms.CheckBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
@@ -33,14 +34,18 @@
this.btnRestart = new System.Windows.Forms.Button();
this.btnOpenAppFolder = new System.Windows.Forms.Button();
this.btnOpenDataFolder = new System.Windows.Forms.Button();
this.checkBrowserGCReload = new System.Windows.Forms.CheckBox();
this.labelApp = new System.Windows.Forms.Label();
this.panelApp = new System.Windows.Forms.Panel();
this.labelPerformance = new System.Windows.Forms.Label();
this.panelPerformance = new System.Windows.Forms.Panel();
this.numMemoryThreshold = new TweetDuck.Core.Controls.NumericUpDownEx();
this.labelMemoryUsage = new System.Windows.Forms.Label();
this.panelConfiguration = new System.Windows.Forms.Panel();
this.labelConfiguration = new System.Windows.Forms.Label();
this.panelApp.SuspendLayout();
this.panelPerformance.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numMemoryThreshold)).BeginInit();
this.panelConfiguration.SuspendLayout();
this.SuspendLayout();
//
@@ -133,6 +138,18 @@
this.toolTip.SetToolTip(this.btnOpenDataFolder, "Opens the folder where your profile data is located.");
this.btnOpenDataFolder.UseVisualStyleBackColor = true;
//
// checkBrowserGCReload
//
this.checkBrowserGCReload.AutoSize = true;
this.checkBrowserGCReload.Location = new System.Drawing.Point(6, 84);
this.checkBrowserGCReload.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3);
this.checkBrowserGCReload.Name = "checkBrowserGCReload";
this.checkBrowserGCReload.Size = new System.Drawing.Size(190, 17);
this.checkBrowserGCReload.TabIndex = 4;
this.checkBrowserGCReload.Text = "Enable Browser Memory Threshold";
this.toolTip.SetToolTip(this.checkBrowserGCReload, resources.GetString("checkBrowserGCReload.ToolTip"));
this.checkBrowserGCReload.UseVisualStyleBackColor = true;
//
// labelApp
//
this.labelApp.AutoSize = true;
@@ -172,20 +189,63 @@
//
this.panelPerformance.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panelPerformance.Controls.Add(this.checkBrowserGCReload);
this.panelPerformance.Controls.Add(this.numMemoryThreshold);
this.panelPerformance.Controls.Add(this.labelMemoryUsage);
this.panelPerformance.Controls.Add(this.checkHardwareAcceleration);
this.panelPerformance.Controls.Add(this.btnClearCache);
this.panelPerformance.Location = new System.Drawing.Point(9, 137);
this.panelPerformance.Name = "panelPerformance";
this.panelPerformance.Size = new System.Drawing.Size(322, 54);
this.panelPerformance.Size = new System.Drawing.Size(322, 105);
this.panelPerformance.TabIndex = 3;
//
// numMemoryThreshold
//
this.numMemoryThreshold.Increment = new decimal(new int[] {
50,
0,
0,
0});
this.numMemoryThreshold.Location = new System.Drawing.Point(202, 82);
this.numMemoryThreshold.Maximum = new decimal(new int[] {
3000,
0,
0,
0});
this.numMemoryThreshold.Minimum = new decimal(new int[] {
200,
0,
0,
0});
this.numMemoryThreshold.Name = "numMemoryThreshold";
this.numMemoryThreshold.Size = new System.Drawing.Size(97, 20);
this.numMemoryThreshold.TabIndex = 3;
this.numMemoryThreshold.TextSuffix = " MB";
this.toolTip.SetToolTip(this.numMemoryThreshold, "Minimum amount of memory usage by the browser process to trigger the cleanup.\r\nTh" +
"is is not a limit, the usage is allowed to exceed this value.");
this.numMemoryThreshold.Value = new decimal(new int[] {
350,
0,
0,
0});
//
// labelMemoryUsage
//
this.labelMemoryUsage.AutoSize = true;
this.labelMemoryUsage.Location = new System.Drawing.Point(3, 66);
this.labelMemoryUsage.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelMemoryUsage.Name = "labelMemoryUsage";
this.labelMemoryUsage.Size = new System.Drawing.Size(78, 13);
this.labelMemoryUsage.TabIndex = 2;
this.labelMemoryUsage.Text = "Memory Usage";
//
// panelConfiguration
//
this.panelConfiguration.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panelConfiguration.Controls.Add(this.btnEditCSS);
this.panelConfiguration.Controls.Add(this.btnEditCefArgs);
this.panelConfiguration.Location = new System.Drawing.Point(9, 238);
this.panelConfiguration.Location = new System.Drawing.Point(9, 289);
this.panelConfiguration.Name = "panelConfiguration";
this.panelConfiguration.Size = new System.Drawing.Size(322, 29);
this.panelConfiguration.TabIndex = 5;
@@ -194,7 +254,7 @@
//
this.labelConfiguration.AutoSize = true;
this.labelConfiguration.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
this.labelConfiguration.Location = new System.Drawing.Point(6, 215);
this.labelConfiguration.Location = new System.Drawing.Point(6, 266);
this.labelConfiguration.Margin = new System.Windows.Forms.Padding(0, 21, 0, 0);
this.labelConfiguration.Name = "labelConfiguration";
this.labelConfiguration.Size = new System.Drawing.Size(104, 20);
@@ -212,10 +272,11 @@
this.Controls.Add(this.panelApp);
this.Controls.Add(this.labelApp);
this.Name = "TabSettingsAdvanced";
this.Size = new System.Drawing.Size(340, 277);
this.Size = new System.Drawing.Size(340, 328);
this.panelApp.ResumeLayout(false);
this.panelPerformance.ResumeLayout(false);
this.panelPerformance.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numMemoryThreshold)).EndInit();
this.panelConfiguration.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -239,5 +300,8 @@
private System.Windows.Forms.Panel panelPerformance;
private System.Windows.Forms.Panel panelConfiguration;
private System.Windows.Forms.Label labelConfiguration;
private System.Windows.Forms.Label labelMemoryUsage;
private Controls.NumericUpDownEx numMemoryThreshold;
private System.Windows.Forms.CheckBox checkBrowserGCReload;
}
}

@@ -23,6 +23,10 @@ namespace TweetDuck.Core.Other.Settings{
checkHardwareAcceleration.Checked = false;
}
checkBrowserGCReload.Checked = Config.EnableBrowserGCReload;
numMemoryThreshold.Enabled = checkBrowserGCReload.Checked;
numMemoryThreshold.SetValueSafe(Config.BrowserMemoryThreshold);
BrowserCache.CalculateCacheSize(bytes => this.InvokeSafe(() => {
if (bytes == -1L){
btnClearCache.Text = "Clear Cache (unknown size)";
@@ -37,6 +41,9 @@ namespace TweetDuck.Core.Other.Settings{
btnClearCache.Click += btnClearCache_Click;
checkHardwareAcceleration.CheckedChanged += checkHardwareAcceleration_CheckedChanged;
checkBrowserGCReload.CheckedChanged += checkBrowserGCReload_CheckedChanged;
numMemoryThreshold.ValueChanged += numMemoryThreshold_ValueChanged;
btnEditCefArgs.Click += btnEditCefArgs_Click;
btnEditCSS.Click += btnEditCSS_Click;
@@ -59,6 +66,15 @@ namespace TweetDuck.Core.Other.Settings{
PromptRestart();
}
private void checkBrowserGCReload_CheckedChanged(object sender, EventArgs e){
Config.EnableBrowserGCReload = checkBrowserGCReload.Checked;
numMemoryThreshold.Enabled = checkBrowserGCReload.Checked;
}
private void numMemoryThreshold_ValueChanged(object sender, EventArgs e){
Config.BrowserMemoryThreshold = (int)numMemoryThreshold.Value;
}
private void btnEditCefArgs_Click(object sender, EventArgs e){
DialogSettingsCefArgs form = new DialogSettingsCefArgs();