Do you use D's GC?

Guillaume Piolat first.last at gmail.com
Mon Aug 2 08:25:28 UTC 2021


On Sunday, 1 August 2021 at 08:54:05 UTC, Kirill wrote:
> It's interesting to hear do you use D's GC? Or do you use your 
> own custom memory management structure?
>
> How performant is GC?
>
> The reason I'm asking is I'm planning to dive into 3D game dev 
> with D as a hobby in an attempt to create a game I dreamed of 
> since I was a kid. I'd like to know if GC is worth using at 
> all, or should I go with 100% manual memory management.
>
> Any opinion is appreciated. Thanks in advance.

For Vibrant which is a very simple game 
(https://store.steampowered.com/app/712430/Vibrant/) I did get 
some GC pauses so the mitigation I used in the end was:
- memory pools
- deregistering audio thread, using core.atomic for game => audio 
communication
- minimize GC heap size. In particular, a GC void[] will be 
scanned but an ubyte[] won't IIRC.

All in all any time spent with GC optimization is well 
compensated by all the time the GC (and D) gives you in tooling, 
and non-realtime stuff.

Don't go with 100% manual memory management if you can avoid it! 
But you can go deterministic destruction with 
https://dlang.org/library/core/memory/gc.in_finalizer.html


More information about the Digitalmars-d mailing list