Garbage Collection and gamedev - tl;dr Yes we want it, so let's solve it

Elronnd elronnd at
Wed Nov 25 08:32:37 UTC 2020

On Wednesday, 25 November 2020 at 07:54:57 UTC, Araq wrote:
> This problem -- if it really comes up -- is not part of the 
> reference counting mechanism at all. Manual memory management 
> with free() calls produces exactly the same effect.

That's not true.  The problem with reference counting is that the 
deallocation happens behind your back, and can be difficult to 
reason about or occur inconsistently.  With manual free calls, 
everything happens explicitly, and you have more flexibility 
about it.

All this aside the fact that, for games, automatic memory 
management isn't competing with 'malloc', it's competing with 
custom arenas.  Where you can deallocate everything at once and 
not have to worry about tracing an object graph.

Malloc is fairly slow as is, and the overhead of reference 
counting on top of it is generally acceptable (esp. with 
optimizations), but rc still has pathological cases.

More information about the Digitalmars-d mailing list