Summary of C + + technical Issues-8th how STL memory pools are implemented

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.