As of now, the game engine uses the default new and delete operators to dynamically allocate and free memory. As the project becomes larger with bigger systems, there is a requirement of a custom memory allocator. Certain systems such as the asset system will benefit from this as there are a lot of memory allocations involved in handling assets.
Features required in the custom memory allocator
- Custom operators for allocating and freeing memory in the heap with fast allocation and deallocation.
- Allocator must be optimized for current use case (i.e., mostly asset management. Will later explore the other use cases)
- The custom memory allocators must be used with the other STL containers and algorithms.
- Custom implementation of smart pointers (such as
std::shared_ptr) with a reference counting system.
- Means of debugging memory allocations and possible memory leaks using external tools such as Valgrind.
By implementing a custom allocator with these features, the asset system and other systems will benefit from better control over how memory is used, all while maintaining compatibility with existing C++ containers and tools.
As of now, the game engine uses the default
newanddeleteoperators to dynamically allocate and free memory. As the project becomes larger with bigger systems, there is a requirement of a custom memory allocator. Certain systems such as the asset system will benefit from this as there are a lot of memory allocations involved in handling assets.Features required in the custom memory allocator
std::shared_ptr) with a reference counting system.By implementing a custom allocator with these features, the asset system and other systems will benefit from better control over how memory is used, all while maintaining compatibility with existing C++ containers and tools.