[Mono-list] question about regular expressions in Mono on
Windows
Tomar
tomar@apricot.com
01 Aug 2004 01:56:57 -0500
--=-OTheJNEk7s7WMLSBXEfH
Content-Type: text/plain
Content-Transfer-Encoding: quoted-printable
Are you sure its a memory leak? Since its managed memory, unless you
specifically dispose of objects or do some of the System.GC stuff or
give it a good reason too (like push memory usage to the limit) the
virtual machine has little reason to reclaim any memory. Its an
"expensive" operation to walk the objects constantly looking for things
to release. I'm not saying that the Regex object is error free or can't
be improved but allocating memory isn't out of the ordinary.
Just out of curiosity have you tried using "csc" and MS's .Net Framework
1.1 to see if it eats as much?
Tom Larsen
On Sat, 2004-07-31 at 08:35, Davy Brion 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.
>=20
> 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.
>=20
> 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.
>=20
> the following testcase illustrates the problem on Windows:
>=20
> using System;
> using System.Text;
> using System.Text.RegularExpressions;
> using System.Threading;
>=20
> class MainClass
> {
> public static void Main(string[] args)
> {
> Match match;
> string strPattern =3D @"\w \w \w \w \w: \d";
>=20
> for (long i=3D0;i<50000;i++)
> {
> string strTest =3D "This is a simple test: " +
> i.ToString() ;
> match =3D Regex.Match(strTest,strPattern);
> Console.WriteLine(i);
> Thread.Sleep(10);
> }
> }
> }
>=20
> 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.
>=20
> i'm using the combined mono/gtk# installer for windows if that makes
> any difference.
>=20
> thanks
> _______________________________________________
> Mono-list maillist - Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
--=20
Tomar <tomar@apricot.com>
--=-OTheJNEk7s7WMLSBXEfH
Content-Type: application/pgp-signature; name=signature.asc
Content-Description: This is a digitally signed message part
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
iD8DBQBBDJQ5KaYNoZecAvQRAnQRAJ0S3OL/JVE8hHAlIRttJvN5Qhem+ACeJjz6
EHjzfvwVgQtX+kDoMl3IW6U=
=1ITq
-----END PGP SIGNATURE-----
--=-OTheJNEk7s7WMLSBXEfH--