Memory pool

Memory pool

Memory pools, also called fixed-size-blocks allocation, allow dynamic memory allocation comparable to malloc or C++'s operator new. As those implementations suffer from fragmentation because of variable block sizes, it can be impossible to use them in a real time system due to performance. A more efficient solution is preallocating a number of memory blocks with the same size called the memory pool. The application can allocate, access, and free blocks represented by handles at run time.

Many real-time operating systems use memory pools, such as the Transaction Processing Facility.

Some systems, like the web server Nginx, use the term memory pool to refer to a group of variable-size allocations which can be later deallocated all at once. This is also known as a region; see region-based memory management.


Sample memory pool implementation

A simple memory pool module can allocate for example 3 pools at compile time with block sizes optimized for the application which deploys the module. The application can allocate, access and free memory with the following interface:

  • To allocate memory from the pools. The function will determine the pool where the required block fits in. If all blocks of that pool are already reserved, the function tries to find one in the next bigger pool(s). An allocated memory block is represented with a handle.
  • To get an access pointer to the allocated memory.
  • To free the formerly allocated memory block.
  • The handle can for example be implemented with an unsigned int. The module can interpret the handle internally by dividing it into pool index, memory block index and a version. The pool and memory block index allow fast access to the corresponding block with the handle, while the version, which is incremented at each new allocation, allows detection of handles whose memory block is already freed (caused by handles retained too long).

Memory pool vs malloc


  • Memory pools allow memory allocation with constant execution time (no fragmentation). The memory release for thousands of objects in a pool is just one operation, not one by one if malloc is used to allocate memory for each object.
  • Memory pools can be grouped in hierarchical tree structures, which is suitable for special programming structures like loops and recursions.
  • Fixed-size block memory pools do not need to store allocation metadata for each allocation, describing characteristics like the size of the allocated block. Particularly for small allocations, this provides a substantial space savings.
  • Memory pools will automatically grow in size to accommodate programs which require more memory than the original pool contained, until of course there is no more memory available on the system.
  • In memory pools, memory usage bugs and bloating can be difficult to diagnose and fix regardless of the API, but the pool construct provided by APR has proven a tremendously convenient, time-saving bit of functionality.


  • Memory pools may need to be tuned for the application which deploys them.

See also


External links

Wikimedia Foundation. 2010.

Игры ⚽ Поможем написать реферат

Look at other dictionaries:

  • Memory Pool System — The Memory Pool System (MPS) is a flexible and modular memory management system that was developed by Harlequin to support both their ScriptWorks PostScript RIP, and their Harlequin Dylan compiler and IDE for the Dylan programming language. As… …   Wikipedia

  • Memory management — is the act of managing computer memory. The essential requirement of memory management is to provide ways to dynamically allocate portions of memory to programs at their request, and freeing it for reuse when no longer needed. This is critical to …   Wikipedia

  • Pool — may refer to: Bodies of water*Plunge pool, small, deep body of water *The River Pool, river in England, tributary to the River Ravensbourne *Reflecting pool, shallow pool of water designed to reflect a structure and its surroundings: **Capitol… …   Wikipedia

  • Memory virtualization — In computer science, memory virtualization decouples volatile random access memory (RAM) resources from individual systems in the data center, and then aggregates those resources into a virtualized memory pool available to any computer in the… …   Wikipedia

  • Pool (computer science) — A pool in computer science is a set of initialised resources that are kept ready to use, rather than allocated and destroyed on demand. A client of the pool will request an object from the pool and perform operations on the returned object. When… …   Wikipedia

  • Dynamic memory allocation — In computer science, dynamic memory allocation is the allocation of memory storage for use in a computer program during the runtime of that program. It can be seen also as a way of distributing ownership of limited memory resources among many… …   Wikipedia

  • Encoding (memory) — Memory has the ability to encode, store and recall information. Memories give an organism the capability to learn and adapt from previous experiences as well as build relationships. Encoding allows the perceived item of use or interest to be… …   Wikipedia

  • Declarative memory — (sometimes referred to as explicit memory) is one of two types of long term human memory. It refers to memories which can be consciously recalled such as facts and knowledge.[1] Its counterpart is known as non declarative or Procedural memory,… …   Wikipedia

  • Object pool pattern — For the article about a general pool see Pool (Computer science) In computer programming, an object pool is a software design pattern. An object pool is a set of initialised objects that are kept ready to use, rather than allocated and destroyed… …   Wikipedia

  • Sweet Memory Hotel Apartments — (Гувия,Греция) Категория отеля: 4 звездочный отель Адрес: Goúvai , Гув …   Каталог отелей

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”