4 ms·
Not a bad article but it misses a style that used to be (and still is, depending on where you look) common on game development: Arena based allocation. Use lot
by yoklov 11y ago
Not a bad article but it misses a style that used to be (and still is, depending on where you look) common on game development: Arena based allocation.
Use lots of arenas. A per frame arena, a per level arena, each subsystem gets its own arena... etc. Shove anything that would be in a dynamic array into ring buffer, unless you can spare the holes in the arena (for per-frame stuff you usually can), of fill it as you allocate. Anything that has a more complicated lifetime than this either gets shoved into a free list or a pool.
And then thats it. Takes a little getting used to (mainly because dynamic arrays become a kind of bad idea) but once you're used to it you really never spend much time worrying about memory management. Caller vs callee free? Neither, it lives in the arena (etc).
It's also extremely fast, as arenas are more or less the cheapest memory allocation strategy, and you can very easily bound the memory usage of your program (needed in game dev a lot, for min requirements), since its patterns are so predictable.
Not sure how well it would translate to other areas... Lack of strings in game dev probably make this much more feasible that it might otherwise be.
- slowmovintarget 11y agoMaybe I'm unfamiliar with the terminology, but isn't that a buffer?
- yoklov 11y agoIt is a buffer (so is any array in C or C++), but it's usage is entirely different from the style described in the article.