Is the garbage collector in .net system-wide or application-wide?

前端 未结 4 1158
囚心锁ツ
囚心锁ツ 2020-12-16 15:28

During discussion with my collegue, I got a doubt that the garbage collector in .net works system wide or application wide.

Means if every application having its ow

相关标签:
4条回答
  • 2020-12-16 15:58

    Every application has its own heap and .NET runtime instance, and so it also has its own garbage collector thread.

    0 讨论(0)
  • 2020-12-16 16:16

    Each process has its own managed heap, which will be collected separately.

    There's no system-wide heap, so there can be no system-wide GC.

    (If you're running multiple CLRs in the same process, they'd each have their own GC too. That's a pretty rare situation though.)

    0 讨论(0)
  • 2020-12-16 16:19

    There is a Garbage Collector per process in the Workstation\Server version of the .Net runtime. GC introduces a CPU overhead per managed process.

    Whether this has an impact on system performance depends on how many managed processes you have and if they are spending a lot of time collecting garbage. You can analyse how much time your process is spending collecting garbage by inspecting performance counter "% Time Spent In GC".

    0 讨论(0)
  • 2020-12-16 16:24

    Have a look at this page (http://msdn.microsoft.com/en-us/library/ee787088.aspx), especially under the section The Managed Heap. That should answer your questions.

    0 讨论(0)
提交回复
热议问题