DD::Image::BlockAllocator Class Reference

Inherits DD::Image::IAllocator.

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)
 
virtual const char * getName () const
 
virtual const char * getType () const
 
virtual size_t getAllocatorUsage () const
 
virtual size_t getAllocatorHighWaterMark () const
 
virtual size_t getRequestedUsage () const
 
virtual size_t getRequestedHighWaterMark () const
 
virtual void resetHighWaterMark ()
 

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.
 

Detailed Description

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



©2021 The Foundry Visionmongers, Ltd. All Rights Reserved.
www.thefoundry.co.uk