Handmade Network»Forums
199 posts
Question on Casey's memory allocation implementation
Edited by Jason on Reason: Initial post
As far as I understand, Casey originally had his memory allocation setup so that he could just separate the allocated memory block into separate 'memory arenas'. So you could have a memory arena allocated for all world objects you'll create, an arena for all assets, an arena for a render buffer, etc. But later on he added the possibility of a 'sub-arena' to sub allocate an arena even further. I was wondering what the purpose of the sub-arena's were and if they are really necessary? I ask this because I was thinking of creating a memory scheme based off his but I figured it would look something like:

i32 generalHeap_id = CreateParitionFromMemoryBlock(gameMemoryBlock, Megabytes(100), DYNAMIC); 
i32 assets_id = CreateParitionFromMemoryBlock(gameMemoryBlock, Megabytes(200), FRAME); 
i32 renderBuffer_id = CreateParitionFromMemoryBlock(gameMemoryBlock, Megabytes(10), LINEAR); 

i32* thing = Alloc(gernalHeap_id, i32, 1);
Render_Command* command = Alloc(renderBuffer_id, Render_Command_Type, 1);


Basically I would be partitioning off memory arena's and specifying what type of allocation scheme I want to run on each of them when allocating memory. I thought this would handle most situations but I'm wondering what I might be missing and if I need to add in the possibility to sub-allocate an arena even further?
Simon Anciaux
1057 posts
Question on Casey's memory allocation implementation
SubArena is just a simple way to reserve a block of memory. It's equivalent to your CreatePartitionFromMemoryBlock function (you wrote parition instead of partition, unless parition means something).
199 posts
Question on Casey's memory allocation implementation
Haha, na, I just misspelled partition. Okay, so it's really not much different from what I'm already doing. Thanks!