G
Guest
I am using Regex.Match in a large application and the memory is growing out of control. I have tried several ways to try and release the memory and none of them work. Here are some similar examples of what I have tried...
string testString = "lkf slkdjflksd sdfjlksdjff fsdjlsdfj flk;sjkf";
while(true)
{
Regex .Match(testString,@"(\w)");
}
----------------------------------------------------------------------
string testString = "lkf slkdjflksd sdfjlksdjff fsdjlsdfj flk;sjkf";
while(true)
{
Regex rx = new Regex(testString);
Match m = rx.Match(@"(\w)");
}
----------------------------------------------------------------------
string testString = "lkf slkdjflksd sdfjlksdjff fsdjlsdfj flk;sjkf";
Regex rx;
Match m;
while(true)
{
rx = new Regex(testString);
m = rx.Match(@"(\w)");
}
----------------------------------------------------------------------
string testString = "lkf slkdjflksd sdfjlksdjff fsdjlsdfj flk;sjkf";
Regex rx;
Match m;
while(true)
{
rx = new Regex(testString);
m = rx.Match(@"(\w)");
rx = null;
m = null;
}
etc. etc. etc.
In all cases the memory grows to over 100megs in a matter of seconds and is never released. In my application the memory grows into the gigabytes and becomes unusable. Do you know what I can do to release the memory? If not do you know another way I can uses match functionality without getting this behaviour?
Cheers,
Jeff.
string testString = "lkf slkdjflksd sdfjlksdjff fsdjlsdfj flk;sjkf";
while(true)
{
Regex .Match(testString,@"(\w)");
}
----------------------------------------------------------------------
string testString = "lkf slkdjflksd sdfjlksdjff fsdjlsdfj flk;sjkf";
while(true)
{
Regex rx = new Regex(testString);
Match m = rx.Match(@"(\w)");
}
----------------------------------------------------------------------
string testString = "lkf slkdjflksd sdfjlksdjff fsdjlsdfj flk;sjkf";
Regex rx;
Match m;
while(true)
{
rx = new Regex(testString);
m = rx.Match(@"(\w)");
}
----------------------------------------------------------------------
string testString = "lkf slkdjflksd sdfjlksdjff fsdjlsdfj flk;sjkf";
Regex rx;
Match m;
while(true)
{
rx = new Regex(testString);
m = rx.Match(@"(\w)");
rx = null;
m = null;
}
etc. etc. etc.
In all cases the memory grows to over 100megs in a matter of seconds and is never released. In my application the memory grows into the gigabytes and becomes unusable. Do you know what I can do to release the memory? If not do you know another way I can uses match functionality without getting this behaviour?
Cheers,
Jeff.