Is there
- one Garbage Collector for an entire system
- one instance of a garbage collector for each user that is logged in
- one garbage collector for each running .NET application
Or is it none of the above (please explain)?
Is there
Or is it none of the above (please explain)?
There is one GC thread per .NET process and therefore one Heap per process. However, the objects are mapped to the individual AppDomains in order to provide process isolation benefits. While there can be more than one AppDomain within a process, by default there is only one per process.
What this means is that for a typical deployment of an application (called MyApp.exe) in a Terminal Services environment, the distinct instances of the .NET application that users are running will each have independent heaps and active memory management. More importantly, the Terminal Services sessions themselves represent a memory boundary of sorts given that sessions are unloaded when the user logs off (http://msdn.microsoft.com/en-us/library/aa383496(VS.85).aspx).
The following illustrates how MyApp.exe would be loaded for each Terminal Services session, and it explains some settings that could impact memory availability and performance within a session: http://blogs.technet.com/askperf/archive/2007/07/24/sessions-desktops-and-windows-stations.aspx
Please refer to Jon Skeet's response here for more detail: http://stackoverflow.com/questions/241537/what-is-the-scope-of-finalizer-thread-per-application-domain-or-per-process
Additionally, the following article explains how Microsoft is now allowing side-by-side CLR instances so that multiple versions of the CLR can be run at the same time. This applies to Silverlight specficially: http://msdn.microsoft.com/en-us/magazine/cc721609.aspx
Also, it appears that the this feature is going to be supported for all future versions of the CLR: http://blogs.msdn.com/davbr/archive/2008/11/10/new-stuff-in-profiling-api-for-upcoming-clr-4-0.aspx
There is on garbage collector per CLR instance in a process. It is possible for multiple instances of the CLR to be running in the same process but that is a pretty rare scenario. In general, there is one CLR per process.