C++14 a significant optimization of memory allocation performance

Source: Internet
Author: User

Table of Contents
    • 1. Essential Needs
    • 2. Problems that exist
    • 3. Solution

Briefly, the C++14 Standard's description modification of memory optimization will allow the compiler to introduce a memory allocation optimization strategy similar to that of the tcmalloc, without sticking to the original one that has a new statement that allocates memory for a silly situation. Therefore, it is reasonable to believe that the C + + program compiled by C++14 compiler can improve the performance of the memory allocation. The following text is derived from the documentation provided by the Clang compiler, and I have made a free translation of its main content. The personal feeling is that you no longer need to introduce TCMALLOC libraries to help improve performance, just use c++14 directly.

1 Essential needs

Need to optimize memory allocation and recycling

    • The allocation and recycling of memory has become a very important cost for modern systems.
    • Differentiate memory allocation optimizations and call optimizations
    • A good system performance requires a different allocation strategy for the dynamic behavior of the application, or a different allocation strategy based on the clues provided by the application.
2 Problems that exist
    • The current C + + standard may cause
      • The allocation policy only considers things that are related to the order of the new/delete statements, ignoring other important information that helps to optimize
      • The allocation policy only considers the invocation statement that allocates memory for each new statement, ignoring the optimization of the allocation
3 Solution Solutions

It is recommended that the wording of the standard document be modified so that more accurate focus is given to the intrinsic requirements, allowing some compiler and memory allocators to support the optimized behavior that is embodied, such as Tcmalloc.

    • In some cases, the number of calls to the memory allocation function cannot be observed in the program. This allows the implementing person to reduce the number of calls (by avoiding calls or merging calls)
    • Avoid calls or merge calls that do not allocate more space than the new statement in the code requires, with the exception of requiring additional memory to fill the gap in order to accommodate memory alignment requirements.

This recommendation does not apply to the class-specific memory allocator

    • The proposed standard directly describes the implementation to comply with Data-race free rules, reference data-race free history and Data-race free principle

Author:dean

Created:2015-12-27 Day 16:17

Validate


C++14 a significant optimization of memory allocation performance

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.