From ba3bceadaec15b9e1b56460de16351a37d940601 Mon Sep 17 00:00:00 2001 From: John Date: Fri, 20 Nov 2015 20:59:25 +0000 Subject: [PATCH] =?UTF-8?q?Added=20a=20forced=20garbage=20collection=20to?= =?UTF-8?q?=20fix=20an=20Out=20Of=20Memory=20bug=20that=20results=20from?= =?UTF-8?q?=20using=20.Net=E2=80=99s=20Regex=20functions=20(which=20do=20n?= =?UTF-8?q?ot=20properly=20reclaim=20memory)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PROMS/Volian.Controls.Library/StepRTB.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/PROMS/Volian.Controls.Library/StepRTB.cs b/PROMS/Volian.Controls.Library/StepRTB.cs index 51b0525a..a234f432 100644 --- a/PROMS/Volian.Controls.Library/StepRTB.cs +++ b/PROMS/Volian.Controls.Library/StepRTB.cs @@ -2517,6 +2517,7 @@ namespace Volian.Controls.Library if (SelectionStack.Count == 0) _SelectionStack = null; Select(selection.SelectionStart, selection.SelectionLength); + selection = null; } public class SelectionData { @@ -2572,6 +2573,7 @@ namespace Volian.Controls.Library } private void FindLinks() { + //int oldRegexCacheSize = Regex.CacheSize; string str = Text; _LinkLocations = new List(); MatchCollection matches = Regex.Matches(str, @"", RegexOptions.Singleline); @@ -2586,6 +2588,9 @@ namespace Volian.Controls.Library match.Value, matchrtf.Index, matchrtf.Length, thisLink); _LinkLocations.Add(thisLink); } + //Regex.CacheSize = 0; + GC.Collect(); // there is a memory leak in Regex this fixes it. + //Regex.CacheSize = oldRegexCacheSize; } private LinkLocation FindBetweenLinks() {