If you’re building software tuned for performance (in C++ or a similar language), you probably know
this as a golden rule: Avoid memory allocations in your performance-critical code at (almost) all
costs. However, sometimes that’s just not feasible and you need to make sure that your allocations
are as efficient as possible.
In a recent project of mine (where performance is not of utmost importance, but also not negligible),
I am not only in the situation that I need to allocate lots of small-ish objects with high
frequency, but I also want to use std::shared_ptr
for memory safety reasons.
In this article, I look into how pool allocators (especially boost::pool_allocator
) can help in
this situation.