Is it possible to stop .NET garbage collection?
No, there is not. At best you can trigger garbage collection yourself, though this is considered to be a Very Bad Thing since it can interfere with the built in scheduling algorithms used by the GC.
In general, no. And most folks would consider it premature optimization to worry about garbage collection unless you do some profiling and find out that it's really the cause of poor performance in your application.
If you're interested in the nitty gritty of tweaking the GC for performance (or more likely, tweaking your app to improve its performance relative to the GC), MSDN has a pretty decent description of ways to do it.
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.
Since .NET 4.6 it's possible, there are methods in the GC
class:
GC.TryStartNoGCRegion(...)
and GC.EndNoGCRegion()
.