I have a situation where my regular expressions compile extremely slowly on Windows Server 2008. I wrote a small console application to highlight this issue. The app gener
You can pre-compile your regexes using the Regex.CompileToAssembly
method, and then you could deploy the compiled regexes to your server.
I found a solution, given not the correct one, but perfect in my case. For some reason if I leave out the RegexOptions.Compiled
flag, the Regex
is much, much faster. I even managed to execute the Regex
on 100 long phrases in under 65 milliseconds on the 2008 server.
This must be a bug in the .net lib as the uncompiled version is supposed to be much slower than the compiled version. Either way, under 1 millisecond per check is very much acceptable for me :)
I ran into the exact same problem. My app works fine on x86 machines but memory balloons and hangs on x64. Removing the compilation flag did not help. I tried this today on .net 4.0 and the problem remains. If you have a repro, I suggest you file a bug.
I think MSFT knows about this, see the bottom comment here
But let them decide if this is the same bug. Please add a link to your filing here if you file so I can add my comments to it.