Storage Distributor - what is it?

I know storage classes in both C and C ++ (static, extern, auto, register, C ++ also adds mutable and some compiler-specific ones), but I can’t understand that there is a memory allocator . I don’t think he was referring to memory allocators implemented in STL, that it is simple:

+6
source share
2 answers

Everything that is behind operator new and operator delete (not to be confused with the new operator and the delete operator). operator new allocates memory from free storage, and operator delete frees the memory previously allocated by operator new for possible reuse. When the code runs foo *ptr = new foo ( new operator), the compiler generates code that calls operator new to get the desired number of bytes of memory, and then calls the constructor for foo . When the code executes delete ptr ( delete operator), the compiler calls the destructor for foo , then calls operator delete to free the memory.

Note that in this way this term is used in the C ++ 03 standard. In the C ++ 11 standard, it is also used to refer to standard distributors.

+5
source

In the C ++ standard, this term is used to refer to the class of the dispenser used by containers in the STL style - either std::allocator , or a custom custom dispenser that satisfies the requirements specified by C ++ 11 17.6.3.5.

However, it is not a formally defined term, but also appears after a reference to the implementation of free storage, that is, to the dynamic storage allocated by new .

[NOTE. I am referring to the current language specification (2011). As noted in the comments, historical versions of the specification apparently used the term (unofficially) to refer to a free store]

+5
source

All Articles