I haven't personally used this, but does this work?
GC.TryStartNoGCRegion Method
Attempts to disallow garbage collection during the execution of a critical path.
https://docs.microsoft.com/en-us/dotnet/api/system.gc.trysta...
Pretty sure that is wired up like an elevator close button. Never seen it make a difference and not for lack of trying.
Re:GC progress from JDK 8 to JDK 17
by google234123 on Wednesday November 24, 2021 @06:12PM
(#29336312)
Is the .net gc still contained in one gigantic source file?
If I could have only 1 new GC thing from Microsoft, it would be the ability to totally disable GC during the lifetime of a process. I don't even want to be able to turn it back on.
I have a lot of scenarios where I could get away with the cruise missile approach to garbage collection. No reason to keep things tidy if the whole world is gonna get vaporized after whatever activity completes. Why waste cycles cleaning things up when you could be providing less jitter to your users or otherwise processing more things per unit time?