Static Web Service over non-static
-
05-07-2019 - |
Question
Currently I have a web service (WCF) that exposes methods that are set to static.
From a strictly memory/GC perspective, what is different in how the CLR and GC handle static versus non-static objects?
Solution
Static data won't be garbage-collected until the containing AppDomain is shut down; commonly this means the memory will stay allocated until the app is shut down, unless you're doing some kind of special AppDomain management. Non-static objects will be collected by the garbage collector, by the normal rules - no more references, and whenever the GC runs.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow