DD::Image::BlockAllocator Class Reference

Inherits DD::Image::IAllocator.

List of all members.

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 ()

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