I've read this article, which describes how instance vs static methods get called with a .NET regex.
However, what about if the variable itself is static? Does anyone know if .NET does any sort of caching that could potentially cause a memory leak?
Clarification. For example:
public static Regex Foo = new Regex(@"(?:,.*)");
versus:
public static void MyMethod(){
Regex Foo = new Regex(@"(?:,.*)");
}
Is either of those more likely to cause any memory issues than the other? I know the second one will obviously create more instances, but does the first one have any sort of caching of incoming strings to worry about, since it will essentially sit around forever.