Handmade Hero»Forums»Code
Steve Olsen
19 posts / 1 project
None
Memory management strategies used in HMH
Edited by Steve Olsen on
I'm trying to get the various ways casey manages memory and when to use them sorted out.
I think it breaks down like this.

An arena is just a large block (array) of memory. It supports pushing things of any size on but doesn't directly support freeing or reallocation (except all at once).
There are three strategies for using an arena.

Stack allocation
If you need to store objects (could be of various sizes) but don't need to free them (except all at once) you can just push them onto the arena and be done with it.

Pool allocation
If you need to store a set of objects of the same size but they can be created or destroyed, you can push them onto the arena. You can easily support removal with a single free list because they are all the same size and you don't get into weird fragmentation situations you can't recover from.

General allocation
If you need the same arena to support adding and freeing blocks of various sizes you need a general allocator. I think casey only has one of these that is used in asset loading.

Are these the only three strategies used in HMH? Are these the proper names for them?
Steve Olsen
19 posts / 1 project
None
Memory management strategies used in HMH
Also if anyone knows any specific places in episodes he talks about these various strategies that could be a nice little playlist to put together.
Oliver Marsh
193 posts / 1 project
Olster1.github.io
Memory management strategies used in HMH
Edited by Oliver Marsh on
Hi Steveo,

At around 1:01:00 on day 141, Casey talks about stacks with different life spans.