Custom memory Pools (c + + needs to be mastered)

Source: Internet
Author: User

The program requests the appropriate size memory as a memory pool through the system's memory allocation, and then the application's own allocation and release of memory can be done through this memory pool. Only if the memory pool needs to be dynamically expanded, the system needs to call the memory allocation function, and all other times the memory is mastered by the application.

From a thread-safe perspective, memory pools can be split into single-threaded and multithreaded pools

Single-threaded memory pool: Single-threaded memory pool is only used by one thread throughout the lifecycle, so there is no need to consider mutex issues

Multi-threaded memory pools: multithreaded memory pools may be shared by multiple threads, so you need to lock each time you allocate and free memory.

In general, single-threaded memory pools perform better, and multithreaded memory pools are more widely available.

Allocate memory cells from memory pools to points: fixed memory pool and variable memory pool

Fixed memory pool: The size of the memory cells allocated by the application each time from the memory pool has been determined beforehand, is fixed

Variable memory pool: the size of each allocated memory unit can vary on demand

Variable memory pools are more widely used and have lower performance than fixed memory pools.

http://blog.csdn.net/chexlong/article/details/7071922

Custom memory Pools (c + + needs to be mastered)

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.