I'm currently attempting to write a 2D scene graph in C, and I need to decide on a way of storing the child nodes. I'm expecting very many reads and few writes, so a linked list is out of the question due to poor spatial locality of reference, and using realloc
every time to add a child node would probably fragment the free list into oblivion. A pool allocator seems to be the best solution, but I can't seem to find any implementations to use. Does anyone know of an allocator that would efficiently handle random-ish allocations and deallocations of a few hundred small struct
s, or perhaps a better allocation scheme?
Overview. A Pool allocator (or simply, a Memory pool) is a variation of the fast Bump-allocator, which in general allows O(1) allocation, when a free block is found right away, without searching a free-list. To achieve this fast allocation, usually a pool allocator uses blocks of a predefined size.
In C++ computer programming, allocators are a component of the C++ Standard Library. The standard library provides several data structures, such as list and set, commonly referred to as containers. A common trait among these containers is their ability to change size during the execution of the program.
One very common memory usage pattern in game programming, is the need to allocate lots of small blocks of memory of the same size.
I'm preparing to deploy TLSF as a real-time allocator. I haven't had a chance to profile its performance yet, but it seems to work, and the license is right.
According to their docs, its operations execute "a maximum of 168 processor instructions in a x86 architecture". It comes as a single .c file, which compiled without modifications on my system.
Take a look at halloc, it might be of some help.
http://swapped.cc/halloc/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With