FbxMemoryPool Class Reference

FbxMemoryPool Class Reference

#include <fbxmemorypool.h>

Class Description

Class to create a simple fixed-size-blocks memory pool to allocate memory dynamically.

Definition at line 23 of file fbxmemorypool.h.

Public Member Functions

 FbxMemoryPool (size_t pBlockSize, FbxInt64 pBlockCount=0, bool pResizable=true, bool pConcurrent=true)
 Memory pool constructor. More...
 
 ~FbxMemoryPool ()
 Memory pool destructor. More...
 
void Reset ()
 Free memory of all memory blocks from this memory pool, also effectively resetting the block count to zero. More...
 
void * Allocate ()
 Allocate or lock a memory block for usage. More...
 
void Release (void *pMemBlock)
 Dispose or unlock a memory block. More...
 

Constructor & Destructor Documentation

FbxMemoryPool ( size_t  pBlockSize,
FbxInt64  pBlockCount = 0,
bool  pResizable = true,
bool  pConcurrent = true 
)

Memory pool constructor.

Parameters
pBlockSizeThe size of one memory block.
pBlockCountThe count of block that should be pre-allocated.
pResizableWhether memory pool can grow if no block are availalbe upon calling Allocate.
pConcurrentWhether the pool supports concurrent allocation and release operations.
Remarks
All memory blocks must be released before the memory pool is destroyed, otherwise a memory leak will occur.

Memory pool destructor.

Upon destruction, all memory blocks of the pool will be de-allocated.

Member Function Documentation

void Reset ( )

Free memory of all memory blocks from this memory pool, also effectively resetting the block count to zero.

Remarks
The block size and alignment/resize/concurrent support will remain unchanged.
void* Allocate ( )

Allocate or lock a memory block for usage.

Returns
An memory block pointer that can be NULL if the memory pool cannot grow in size and no blocks are available.
void Release ( void *  pMemBlock)

Dispose or unlock a memory block.

Parameters
pMemBlockA pointer to the memory block to release. This will not free the block's memory, instead simply putting it back in the available stack.

The documentation for this class was generated from the following file: