C + + memory Management change

Source: Internet
Author: User

Introduction

Memory management has undergone several changes, but it has not yet matured. These changes mainly include:

1. From Malloc/free to New/delete. This change is the product of the rise of OOP technology. C + + is a strongly typed language, and the main result of New/delete is that it reinforces the concept of type and reduces the need for forced type conversions. But from a memory management perspective, this change is not much of a breakthrough.

2. From New/delete to Memory Configurator (allocator). Since the STL has been incorporated into the C + + standard library, the C + + world has changed dramatically. From the point of view of memory management, the introduction of allocator is also a breakthrough in C + + memory management. Notice that you can see that the entire STL memory is allocated from allocator to all components. That is, the STL does not recommend the use of New/delete for memory management, but recommend the use of allocator.

However, the allocator of STL does not cause the C + + language to change greatly in memory management. In addition to the STL itself, not many people use allocator, or even realize the importance of allocator. Therefore, C + + programmers in the use of STL, while still using new/delete for cumbersome memory allocation/release process.

The main reasons are two. First, the introduction of allocator, STL designers may be based on the memory management from the implementation of the container independent of the design concept of the role, so that STL users in the memory management algorithm has a choice. The designers themselves may not be aware of the importance of allocator. The second is that the allocator itself is focused on efficiency rather than on the change of memory management concepts by C + + language users.

In short, in my opinion, the introduction of STL allocator, is a great thing. But the change has been neglected and not implemented. Of course, this is also related to the defects of the STL allocator itself.

In this paper, it is how to carry out the allocator thought of STL, and make appropriate improvement to it, in order to produce a transformative breakthrough in the concept of C + + memory management, and eliminate the traditional New/delete memory management method completely.

Related Article

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.