3 ms·
> where a GC would help (e.g. when there is no clear ownership hierarchy but a lot of mutual dependencies between objects) Not really. This is a straw man argu
by adev_ 3y ago
> where a GC would help (e.g. when there is no clear ownership hierarchy but a lot of mutual dependencies between objects)
Not really. This is a straw man argument.
Having large graph of object with mutual dependencies represented as references to each other is almost all the time a code smell and a problem of design.
It is terrible for cache locality, terrible for memory fragmentation and will bring even the best GC on its knees.
The way to handle that is to use Entity Component System [^1] or a SOA structue with indexes.
In fact every mature game engine or serious Graph Representation library (which are specially design to deal with these cases) will do exactly that.
[1] https://en.m.wikipedia.org/wiki/Entity_component_system https://en.m.wikipedia.org/wiki/Entity_component_system
- Rochus 3y ago> This is a straw man argument. Of course it can also be done without a GC. > is almost all the time a problem of design There are even cases where this design is unavoidable to solve the problem.