[Mono-list] Re: question about regular expressions in Mono on Windows
Davy Brion
ralinx@gmail.com
Mon, 2 Aug 2004 20:48:04 +0200
in case anyone cares, i filed a bug for this:
http://bugzilla.ximian.com/show_bug.cgi?id=62293
On Sat, 31 Jul 2004 15:35:54 +0200, Davy Brion <ralinx@gmail.com> wrote:
> about six weeks ago, i thought i found a memory leak in the Regular
> Expressions part of Mono, and i mailed a testcase to the mono list but
> Gonzalo said the problem didn't occur when he tried it. This was around
> the mono 1.0 beta2 timeframe iirc.
>
> On Linux, i don't have that problem anymore, but i've recently managed
> to get my application working on Windows (with GTK#) but unfortunately
> it is leaking a lot of memory on Windows. I've tracked it down and it
> turns out that it's because my application uses regular expressions on
> strings a lot. with a lot i mean like almost continiously actually.
> If i comment out the line of code that checks for the regular
> expression, the memory usage is normal. If i let it execute the
> regular expression, and comment out the stuff that should be executed
> after that, i can already see the memory usage going up. This only
> happens on Windows, not on Linux.
>
> I've tried a lot of stuff to work around this problem, but i'm getting
> pretty desperate to be honest. I really have no clue what else i can
> try to avoid this problem.
>
> the following testcase illustrates the problem on Windows:
>
> using System;
> using System.Text;
> using System.Text.RegularExpressions;
> using System.Threading;
>
> class MainClass
> {
> public static void Main(string[] args)
> {
> Match match;
> string strPattern = @"\w \w \w \w \w: \d";
>
> for (long i=0;i<50000;i++)
> {
> string strTest = "This is a simple test: " +
> i.ToString() ;
> match = Regex.Match(strTest,strPattern);
> Console.WriteLine(i);
> Thread.Sleep(10);
> }
> }
> }
>
> if i run that on windows, and i watch the memory usage in the Task
> Manager, the memory just keeps going up. The longer it runs, the more
> memory it uses.
>
> i'm using the combined mono/gtk# installer for windows if that makes
> any difference.
>
> thanks
>