Discussion about deprecating @nogc and workarounds
Walter Bright
newshound2 at digitalmars.com
Mon Sep 9 20:20:13 UTC 2024
gc is a "stop the world" gc, but it can be managed in a real-time environment:
1. Collections are only run when a call to allocate memory from the gc is made.
The gc does not randomly run, and will not run if the code is not calling the gc.
2. Collections can be disabled and enabled.
3. Real time programs have startup and shutdown, where GC can be used, because
the real time part is not running then.
4. Pre-allocate memory for the real time part, so it will not need to allocate
memory.
5. malloc/free can consume arbitrarily large amounts of time.
6. put the real time code in a thread that is not paused by the GC collection
cycle (this also means that thread cannot call the GC, and cannot be the "owner"
of the GC allocations it uses).
7. Minimize the time spent in real-time code by collecting the asynchronous
events and posting them to a queue that the non-real-time code can execute.
More information about the Digitalmars-d
mailing list