See more details: https://zcheng.ren/2016/08/16/STLAllocater/
In the implementation of STL, the Space Configurator is the most important one, because the whole STL operation object is placed in the container, how to allocate space for the container so that the container can store the data. At this time we need to configure the Alloc for processing.
What does the space Configurator alloc include?
The Space Configurator configures the memory. Release is separate from the construction and destructor release of the object, so the STL space Configurator consists of two parts to explain:
1. Construction and deconstruction of objects
For C + + built-in types and user-defined types we have to judge that they need not be destructor;
2, Memory application and release: More than 128b time to call the first-level configurator
To determine when applying for memory space if the request fails, a new configuration function is defined to recycle the space, configure the space, until the memory space is finally found or the memory space can not be requested to exit the loop; Call Level two configurator when less than 128b
Second-level Configurator is more fun, has its own memory pool and a corresponding free list, free list in their own free_list above the application of space, if you can not apply to the memory pool above the memory space application.