Handmade Hero»Forums»Code
Juan Prada
5 posts
About Arenas and Sub-Arenas
Edited by Juan Prada on
I have a few questions about Arenas. First a big amount of memory is allocated using platform layer code ( VirtualAlloc ) then, out of this big chunk, in many places in the code Sub arenas are created. I might be missing something, but After that Sub arena is used, I dont see it being returned to the big chunk so that is is available again for it to be used in some other parts when SubArena is used. Does that mean that whenever SubArena is used, that memory will not be available anymore during the lifetime of the game?

The most similar thing I found is temporary_memory yet it still requires an arena to be passed in order for it to be created, which means a SubArena is used to create a temporary_memory struct.

I am pretty sure I am looking at things wrong, but I am really new to this way of handling memory, so could anyone elaborate a bit on this?

Bill Strong
50 posts
About Arenas and Sub-Arenas
You've got most of it. You just missed the bit where instead of destroying and recreating a subarena, we simply reuse the subarena. After all, it was already perfectly sized for its use.

Now, if you mean after the game is closed, we rely on Windows to clean up the memory for us.