3 ms·
> C# instead, both with Unity and many other open or closed source engines, that either host it as a gamescript language or, lately, implemented entirely in it.
by James_K 2y ago
> C# instead, both with Unity and many other open or closed source engines, that either host it as a gamescript language or, lately, implemented entirely in it.
And this is what confuses me. The opinions of game developers on this seems utterly baseless, and contradicted by the actual practice of the people who write game engines. I've only ever seen one (quite frankly genius) paper[1] on this that explores the question in a satisfying manner, and it suggests that garbage collection has something like a 17% overhead compared with a malloc call, at the cost of 3 times the memory usage. Not great, but it seems like a video game can afford to triple its memory usage given how it works with resources, and also given that a lot of what's allocated will be large assets which won't need to be counted in the 3× overhead since the represent a small number of objects compared to their size.
[1] Matthew Hertz and Emery D. Berger. 2005. Quantifying the performance of garbage collection vs. explicit memory management. SIGPLAN Not. 40, 10 (October 2005), 313–326. https://doi.org/10.1145/1103845.1094836 https://doi.org/10.1145/1103845.1094836
- neonsunset 2y agoWhat do you mean by baseless? I strongly suggest to avoid such papers (unless they are recent and cover the impact of GC strategy as a whole vs how it is implemented) as they are likely to be worse than misleading, because in the area of memory management, a lot of performance lives and dies by implementation details. I tend to treat negatively such academic works because they become outdated fast, and are hard to draw conclusions from. Allocation in competent GC is explicitly cheaper (it's a 1-2 dereferences, and a pointer bump if allocation context/quantum/pool can satisfy the allocation without asking for more memory for the GC itself or without performing collection), you pay the cost later with mark and sweep, and pause time, but most of all, non-deterministic nature of "batch deallocation" of such kind.
- James_K 2y ago> What do you mean by baseless? They say "garbage collection is slow" and when I ask how they know, they have no response. > they are likely to be worse than misleading > they become outdated fast, and are hard to draw conclusions from. Out of interest, how many papers have you read and how have you come to these conclusions? What empirical evidence to you have for these claims? I don't dispute that there is a general lack of research around this area, but that hardly justifies discarding the scientific method. Given that many of them implement techniques which can simply be re-run as new runtimes are released, why do we not do this? With proper CI, you could easily keep this information as up-to-date as necessary. > Allocation in competent GC is explicitly cheaper I am well aware. When I say "allocation", I refer to the entire lifetime of an object. As in both its allocation, residence in memory, and cleanup. Did you read the paper I cited? It provides a strong case that this "lifetime-cost" of an object can be quantified and measured.
- neonsunset 2y ago> Did you read the paper I cited? It provides a strong case that this "lifetime-cost" of an object can be quantified and measured. I will read it in full, thanks.