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

Araq rumpf_a at web.de
Wed Nov 25 09:33:15 UTC 2020


On Wednesday, 25 November 2020 at 08:32:37 UTC, Elronnd wrote:
> 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.
>

That's about implicit vs explicit code, still not about the 
refcounting mechanism. And the flexibility remains in the 
implicit code, move an owner to a different thread/owning data 
structure.

> 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.

Areas still have pathological cases where you never free anything 
whatsoever in a runaway loop...


More information about the Digitalmars-d mailing list