When is it acceptable to call GC.Collect?

前端 未结 24 2590
挽巷
挽巷 2020-11-22 08:54

The general advise is that you should not call GC.Collect from your code, but what are the exceptions to this rule?

I can only think of a few very speci

24条回答
  •  甜味超标
    2020-11-22 09:20

    Since there are Small object heap(SOH) and Large object heap(LOH)

    We can call GC.Collect() to clear de-reference object in SOP, and move lived object to next generation.

    In .net4.5, we can also compact LOH by using largeobjectheapcompactionmode

提交回复
热议问题