Garbage collection in C# not carried out. Why?

后端 未结 5 2003
感动是毒
感动是毒 2021-02-12 03:58

I have tried a simple experiment to verify the functionality of the garbage collector. Referencing 3.9 Automatic memory management (MSDN) about automatic memory managem

5条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-12 04:38

    The CLR does not run the garbage collector for every memory release as it consumes system resources. So the garbage collector is called at regular intervals based on the growing memory size. It would clear all the unrefered memory leaks.

    Also the garbage collector can be called explicitly using the method GC.Collect(), but it is not advisable to use explicitly.

提交回复
热议问题