Replies: 1 comment 3 replies
-
NoGCRegion can provide some functionality around this. However, it needs to be used very carefully about time and allocation speed, or the process will run out of memory quickly.
A GC consists of several phases, some of them are capable to run in a background thread. The "time" is not clearly defined here.
There are such engines implemented with .NET. Reducing GC pause time is a complex topic. There are already discussions like #65850.
The heuristic of GC itself would probably do much better than application. For instance, one situation application can inform GC is that a hugh graph of objects just died. |
Beta Was this translation helpful? Give feedback.
-
Would it be useful to have FULL manual garbage collection in .NET where the program determines when the Garbage Collector runs and to limit the time the GC can run?
new property:
GC.Mode = GCCollectionMode.Manual or GCCollectionMode.Automatic // in addition to the methods that already exist
new method:
GC.Collect(int milliseconds) // specifies the time the GC can take to reclaim memory, only applicable if GC.Mode = Manual
This would allow time sensitive applications like games or video encoding / decoding engines to be written in a .NET language.
In addition the GC could also expose some memory pressure statistics to aid the program in determining when the garbage collection should be run.
Beta Was this translation helpful? Give feedback.
All reactions