C++ Allocator is a class that dictate memory management and address model of #202202241719. We can create an allocator for various memory allocation policy such as stack allocation, per-thread allocation and Arena Allocation.
The usage of allocator mostly consists of allocate
and delloacate
functions which could be treated as new
and delete
respectively. In fact, the default allocator’s implementation encapsulates the new
and delete
using the these two functions.
There are two kinds of propagation involved in allocator design:
For Deep Propagation, we could use scoped_allocator_adaptor
for it. This could be a help on Arena Allocation.
Modern C++(14 and 17) introduce the polymorphic memory resources (std::pmr
) which is not Lateral Propagation. This means that the allocator will be able to stick to the lifetime of the #202202241719. It includes allocators like synchronized_pool_resource
, unsynchronized_pool_resource
and monotonic_buffer_resource
.