Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
The allocator is able to allocate and free memory in the required quantities in a certain way. std::allocator is an example implementation of an allocator from the standard library, just using new and delete, which normally access the malloc and free system calls.
A more complex example is the pool allocator. Since system calls are expensive, why not save on them? Let's allocate 1 gigabyte of memory at once (for example), and then in the allocator we will issue memory from this pool and increase the head pointer (again, simplified). There is only one real memory allocation, there are almost no system calls, hooray, the program has accelerated.
Actually, this is what allocators are for, to insert your own, cool, non-standard, memory allocation anywhere. Most standard containers accept them.
There are a number of smart and understandable articles on Habré, for example this one:
Alternative memory allocators
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question