Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Small objects allocator

Has anybody used SmallObjectAllocator from Modern C++ Design by Andrei Alexandrescu in a big project? I want to implement this allocator but I need some opinions about it before using it in my project. I made some tests and it seems very fast, but the tests were made in a small test environment. I want to know how fast it is when are lots of small objects(like events, smart pointers, etc) and how much extra memory it uses.

like image 986
Mircea Ispas Avatar asked Jun 06 '10 14:06

Mircea Ispas


People also ask

What is fixed size allocator?

Memory pools, also called fixed-size blocks allocation, is the use of pools for memory management that allows dynamic memory allocation comparable to malloc or C++'s operator new.

What does an allocator actually need to do?

Allocators handle all the requests for allocation and deallocation of memory for a given container. The C++ Standard Library provides general-purpose allocators that are used by default, however, custom allocators may also be supplied by the programmer.

What is use of allocator in C++?

Allocators are used by the C++ Standard Library to handle the allocation and deallocation of elements stored in containers. All C++ Standard Library containers except std::array have a template parameter of type allocator<Type> , where Type represents the type of the container element.

What is a bump allocator?

Bump allocation is a fast, but limited approach to allocation. We have a chunk of memory, and we maintain a pointer within that memory. Whenever we allocate an object, we do a quick check that we have enough capacity left in our chunk to allocate the object and then update the pointer by the object's size. That's it!


2 Answers

I suggest you ask Rich Sposato. He has done extensive work on Loki's small object allocator, including testing and benchmarks.

like image 178
Andrei Alexandrescu Avatar answered Sep 21 '22 17:09

Andrei Alexandrescu


Have you considered using Boost Pool Library ?

like image 21
Konstantin Avatar answered Sep 20 '22 17:09

Konstantin