top of page

Arena Allocator

Solo Project

What have been done:

  • Created a function that takes long time to finish

  • Created a simple local area allocator to handle the memory allocation/deallocation operations there

  • Increased the performance of the function by 10 seconds( from 72 to 62)

What are the next steps:

  • Making the arena aligned

  • Diving deep into the topic to increase the performance even more

Technologies Used:

  • C++

  • Visual Studio

GitHub Page:

Details:

For this project I have decided to create my own arena allocator to have a better understanding of memory management. In order to do this I have created a console application function that takes long time to finish the process( in this case it takes 72 seconds) I have timed the seconds using chrono library

​

This function basically creates and new integer array pointer and simulates work inside the array then deletes said array, and does this for multiple times

function_edited_edited.png

In order to improve the performance of the code, instead of getting a new memory from the heap by using the new keyword, an area of the memory can be  allocated from the start and we can handle the memory operations there. For this I have created a very simple linear arena allocator. When its initialized, the arena pre-allocates some given size of memory. It also tracks where is the current offset is. When the allocate function gets called it returns a pointer in memory taking mind of the offset then increases the offset by the size of the type and by the amount of the elements, meaning if it is an array array size times the size of the type. And there is also a reset function that resets the current index to 0.

​

Since the arena is going to be freed when the program gets closed, there is no need to do a deallocation function for this simple allocator.

Using the arena allocator, the time required to finish the function goes down from 72 seconds to 62 seconds. This is a good start but it's not enough. More functionality needed to be added to the arena as well, like alignment. However at the time of writing this, this is still a work in progress project. More updates will arrive as I develop the project more.

bottom of page