Is it possible to stop .NET garbage collection?

前端 未结 4 1037
Happy的楠姐
Happy的楠姐 2020-12-17 17:37

Is it possible for a programmer to programmatically start/stop the garbage collection in C# programming language? For example, for performance optimization and so on.

4条回答
  •  太阳男子
    2020-12-17 18:22

    Since .NET 4.6 it's possible, there are methods in the GCclass:

    GC.TryStartNoGCRegion(...) and GC.EndNoGCRegion().

提交回复
热议问题