Memory Pool)

Source: Internet
Author: User

It seems that the memory pool is a deep topic. Whenever you want to try it, you feel that you have not accumulated enough. Today, we have finally accumulated a memory pool, and there will be time. I have read the alloc in STL, that is, the design idea and Implementation of the Space configurator. The ace block is different from the memory pool.

 

Today, a memory pool is available, which is implemented according to the idea of the STL space empty configurator, that is, the memory block is managed by the vertical and horizontal linked list. Horizontal linked lists manage memory blocks of different sizes, and vertical linked lists manage memory blocks of the same size. To avoid Memory waste, nodes that manage memory blocks use Union, externally, It is the address of memory that can be used, and internally it is directed to the next available memory block.

 

The advantages of using the memory pool are obvious:

1. Avoid frequent requests from the system to release memory fragments;

2. Avoid applying to the system every time the memory is used (new or malloc, new or malloc each time, the efficiency is low );

3. Avoid Memory leakage (you can manage the application and release of memory by yourself, and you can use the idea of resource management objects)

 

Disadvantages:

1. The memory pool implemented by the author only applies to the system and does not return it to the system. That is to say, the memory usage will be stable when it reaches a certain stage, even ifProgramAt this time, the memory is not actually used, but it also occupies a large amount of memory;

 

 

Mempool download

 

 

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.