Pool allocator implementation to minimize memory fragmentation. More...
#include <UTPoolAllocator.h>
Public Member Functions | |
PoolAllocator_t (bool auto_thread_safe) | |
~PoolAllocator_t () | |
void * | Allocate (size_t size) |
void | Release (void *block) |
Pool allocator implementation to minimize memory fragmentation. This should only be used for objects, few of which are created or which are reasonably short-lived and frequently allocated, otherwise as pools are freed in an attempt to keep that memory fragmentation to a minimum, the old blocks will stay allocated and actually make matters worse. If a pool block has been leaked, build the UT library with TRACE_LEAKED_POOL_BLOCK to diagnose where the block was allocated. That facility is only available in debug builds.
Definition at line 60 of file UTPoolAllocator.h.
PoolAllocator_t::PoolAllocator_t | ( | bool | auto_thread_safe | ) |
Constructor. If auto_thread_safe is true, it will allocate a mutex and ensure that calls to Allocate and Release are thread safe.
PoolAllocator_t::~PoolAllocator_t | ( | ) |
Destructor.
void* PoolAllocator_t::Allocate | ( | size_t | size | ) |
Allocates a block from the block pool.
Reimplemented in GUIPoolAllocator_t.
void PoolAllocator_t::Release | ( | void * | block | ) |
Releases a block back to the block pool.
Reimplemented in GUIPoolAllocator_t.