Configuration and release of space Std::alloc

Source: Internet
Author: User

After reading the object's construction behavior and the destructor of the object before the memory is freed, let's look at the configuration and release of the memory.

The space allocation before the object construction and the space release after the destruction are defined in the header file <stl_alloc.h>. Its design idea is:

    • Requires space for the system heap.
    • Consider multithreading status.
    • Consider contingency measures when memory is low.
    • Consider the memory fragmentation issues that may be caused by too many "small chunks".

C + + memory configuration basic operation:: operator new (), the basic operation of memory deallocation is:: operator delete (). This is the malloc () and free () functions that are equivalent to C for the two global functions. Yes, that's exactly what SGI is doing with malloc () and free () to configure and release the memory.

Given the potential for memory fragmentation in small chunks , SGI designed a two-tiered configurator , with the first-level configurator directly using malloc () and free (), The second level uses different strategies depending on the situation: when the configuration chunk exceeds 128bytes, it is considered "large enough" to invoke the first level configurator, which is considered "too small" when the configuration chunk is less than 128bytes . In addition, a complex memory pool arrangement is used. Whether the entire design is open only to the first-level configurator or to the colleague open the second-level configurator depends on if the macro __use_malloc is defined.

Configuration and release of space Std::alloc

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.