If I have a static class with a static field such as:
private static myField = new myObject();
I then have a bunch of static methods that use myField.
Is myField re-instantiated for each method call? My guess is that it’s instantiated the first time a method is called that uses it and it remains in memory until the GC clears it up?
Cheers for any pointers 🙂
No, it is assigned to one time, when the class is first accessed. The GC will not release the memory for this instance while the application is running – the memory will be freed when the AppDomain unloads.