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.
Such a mechanism takes space from the heap and can resolve memory fragmentation issues.
1. Memory Application Flowchart
A brief flowchart such as the following.
2. Second Level configurator description
second level configurator to resolve memory fragmentation problems 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[];
};
has 16 free-lists. The respective management sizes are 8, 16, 24, 32, 40, 48, 56, 64, 72, 80, 88, 96, 104, 112, 120, and bytes of small chunks.
application process such as the following.
release process such as the following.
Summary of technical issues with C + +-8th How STL memory pools are implemented