STL Memory pool mechanism, using a dual-level configurator. The first level uses malloc, free, and the second level uses different strategies depending on the situation. This mechanism takes space from the heap to resolve memory fragmentation issues.
1. Memory Application Flowchart
The brief flowchart is as follows.
2. Second Level configurator description
The second Level Configurator is intended to solve the memory fragmentation problem caused by small chunks.
Use the free list (free-list) technique. Proactively raise the memory requirements of any small chunk to multiples of 8. If demand is 30, increase to 32.
free-list node Structure
Union obj
{
Union obj* Free_list_link;
Char client_data[];
};
There are 16 free-lists, each of which manages small chunks of size 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, Bytes.
The application process is as follows.
The release process is as follows.
Summary of C + + technical Issues-8th how STL memory pools are implemented