[Boost basic] memory management-memory pool Library

Source: Internet
Author: User
Memory Pool

"Pool" is a design pattern often used in computer technology. Its connotation is to apply for the core resources frequently used in the program and put them in a pool, it is managed by the program itself, which can improve resource usage efficiency and ensure the number of resources occupied by the program. Frequently Used eating techniques include memory pools, thread pools, and connection pools. Among them, the most memory pool and thread pool are used.

Memory Pool: in short, the memory pool allocates a block of memory space in advance, and then you can use an algorithm to implement efficient and fast custom memory allocation.

Pool Library

The boost. pool library implements a fast and compact memory pool library based on the simple separation of storage ideas, which can not only manage a large number of objects, but also be used as a memory distributor of STL. To some extent, it is similar to a small garbage collection mechanism. It is very efficient to allocate and release a large number of small objects, and delete is not required at all.

The pool library consists of four components: the simplest pool, the object_pool of the allocation class instance, and the singleton_pool of the single-piece memory pool, which can be used for pool_alloc of the standard library ..

Pool: it can only be used as a memory pool for common data types such as int and double. It cannot be used for complex classes and objects because it only allocates memory and does not call constructors, in this case, we need to use object_pool;

Memory Management

Memory Management is an eternal topic in C ++ program development. Because there is no garbage collection mechanism, careful management of memory and other system resources is a problem that every C ++ programmer must face. The C ++ 98 standard improves auto_ptr, which can automatically release resources, but does not solve all problems. The Boost library improves the smart_ptr library and pool library.

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.