Do you use D's GC?

russhy russhy at gmail.com
Mon Aug 2 02:09:11 UTC 2021


I only use GC for process that doesn't need to be realtime

For anything else (including my game engine) i don't use GC at 
all, instead i use allocators (malloc/free most of the time)

If you plan to make a game, try to avoid the GC as much as 
possible, it's not incremental, so whever it needs to do a 
collection, it'll pause all the threads, depending on the 
structure of the heap memory it can take multiple frames


But that's also a valid concern if you misuse malloc/free, so 
it's not an issue with the GC

But with games, you want to make sure you control the memory 
allocation strategy, and GC doesn't help with that

You can always GC.disable() and call GC.collect() during loading 
screens, but again, control your allocation strategy!



More information about the Digitalmars-d mailing list