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.
Since .NET 4.6 it's possible, there are methods in the GC
class:
GC.TryStartNoGCRegion(...)
and GC.EndNoGCRegion()
.
Not really. You can give the GC
hints via methods like GC.AddMemoryPressure
or GC.RemoveMemoryPressure
but not stop it outright.
Besides, garbage collection is not that intensive of a process. Programmers very rarely ever worry about it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With