|
Blaze 3.9
|
Memory pool for small objects. More...
#include <MemoryPool.h>
Inherits blaze::NonCopyable.
Classes | |
| union | FreeObject |
| A single element of the free list of the memory pool. More... | |
| struct | Block |
| Memory block within the memory bool. More... | |
Public Member Functions | |
Constructor | |
| MemoryPool () | |
| Constructor of the memory pool. | |
Destructor | |
| ~MemoryPool () | |
| Destructor of the memory pool. | |
Private Types | |
| using | Blocks = std::vector<Block> |
| Vector of memory blocks. | |
Private Attributes | |
Member variables | |
| FreeObject * | freeList_ |
| Head of the free list. | |
| Blocks | blocks_ |
| Vector of available memory blocks. | |
Memory management functions | |
| void * | malloc () |
| Allocation of raw memory for an object of type Type. | |
| void | free (void *rawMemory) |
| Deallocation of raw memory for an object of type Type. | |
| bool | checkMemory (FreeObject *rawMemory) const |
| Performing a number of checks on the memory to be released. | |
Memory pool for small objects.
The memory pool efficiently improves the performance of dynamic memory allocations for small objects. By allocating a large block of memory that can be dynamically assigned to small objects, the memory allocation is reduced from a few hundred cycles to only a few cycles.
The memory pool is build from memory blocks of type Block, which hold the memory for a specified number of objects. The memory of these blocks is managed as a single free list.
|
inlineprivate |
Performing a number of checks on the memory to be released.
| toRelease | Pointer to the memory to be released. |
|
inline |
Deallocation of raw memory for an object of type Type.
| rawMemory | Pointer to the raw memory. |
|
inline |
Allocation of raw memory for an object of type Type.