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.