Public Member Functions | |
BlockAllocator (const char *allocatorName, const SmallBlockDefinition definition=SmallBlockDefinition()) | |
void * | allocate (size_t size) |
template<typename T > | |
T * | allocate (size_t numItems) |
template<typename T > | |
T * | New () |
void | deallocate (void *memory) |
template<typename T > | |
void | Delete (T *memory) |
const char * | getName () const override |
const char * | getType () const override |
size_t | getAllocatorUsage () const override |
size_t | getAllocatorHighWaterMark () const override |
size_t | getRequestedUsage () const override |
size_t | getRequestedHighWaterMark () const override |
void | resetHighWaterMark () override |
Additional Inherited Members | |
Static Public Member Functions inherited from DD::Image::IAllocator | |
template<typename T > | |
static T * | getAllocator (IAllocator *pAllocator) |
Helper function for returning a concrete allocator type. | |
Block Allocator
This is a thread-safe allocator that, for particular sizes defined on construction, will allocate in blocks a given size and then use these instead of calling malloc
This stops lots of malloc calls, which will speed up slow system memory calls in most cases, at the expense of a memory overhead.
If a call is made to allocate outside the small block size, then it will call directly through to DD::Image::Memory::allocate()
It also tracks how much memory is currently being used by the given allocator instance
©2024 The Foundry Visionmongers, Ltd. All Rights Reserved. |