samedi 6 juin 2020

Memory allocator for a light tree based data structure for frequent allocation and deallocation

I have a binary tree based data structure that does all operations in O(log N). It allocates / deallocates memory via new and delete. In my typical usage, the data structure is in use for a 40 minutes run and allocates/de-allocates small chunks tree nodes half a billion times. The overall memory footprint of this data structure is low as de-allocation happens soon enough. This has been identified as a performance bottleneck.

I am thinking of overloading operator new and delete or modifying my existing code to be able to use allocators and create a custom allocator for such purpose. I am thinking of allocating contiguous large amount of memory upfront and re-using chunks of memory from it. Does C++11 standard have such a pool based memory allocator?

What memory allocation/de-allocation strategy would be best suited for such usage?

Aucun commentaire:

Enregistrer un commentaire