Handmade Hero » Forums » Code » Memory management strategies used in HMH
steve
Stephen Olsen
19 posts
1 project
Software Engineer from Chicago. Data processing / web infrastructure by day, AI ...
#4791 Memory management strategies used in HMH
2 years ago Edited by Stephen Olsen on Sept. 16, 2015, 4:58 p.m.

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
Stephen Olsen
19 posts
1 project
Software Engineer from Chicago. Data processing / web infrastructure by day, AI ...
#4792 Memory management strategies used in HMH
2 years ago

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.
OliverMarsh
Oliver
17 posts
1 project

A budding game developer and programmer

#4796 Memory management strategies used in HMH
2 years ago Edited by Oliver on Sept. 16, 2015, 10:13 p.m.

Hi Steveo,

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