Taking a heaptrack memory profile of the default allocator revealed 2,000,000 heap allocations when adding, deleting, and re-adding 1,000,000 entries to an std::unordered_map.
To avoid heap allocations in the application's hot path, the solution proposed involves using a memory pool in conjunction with a custom allocator.
The custom allocator's implementation includes functions allocate() and deallocate(), complying with std::allocator_traits for proper interfacing with the standard library.
By implementing the custom allocator and utilizing a memory pool, transitioning from heap to stack memory allocation was successful, as observed in the heaptrack memory profile.