Proud::CLookasideAllocator Class Referenceabstract

Public Member Functions

virtual void * Alloc (size_t size)=0
 
virtual void Free (void *ptr)=0
 
virtual int DebugCheckConsistency ()=0
 

Static Public Member Functions

static CLookasideAllocatorNew (const CFastHeapSettings &settings=CFastHeapSettings())
 

Detailed Description

Performs very high speed memory allocation/disengagement but there are some restrictions.

  • Memory of same size can only be allocated at all time.
  • The object allocated by this cannot be global variable. In other words, the destruction time of this allocator must come prior to the desruction time of allocated object.

Characteristics

  • Allocate memory block of memory page unit in advance and then use it, so it is recommended not to make too many CLookasideAllocator instances.
  • Memory page is allocated to VirtualAlloc. Since it will not create internal fragmentation, it brings an effect of reducing the size of win32 working set.

Member Function Documentation

virtual void* Proud::CLookasideAllocator::Alloc ( size_t  size)
pure virtual

Allocate memory.

virtual int Proud::CLookasideAllocator::DebugCheckConsistency ( )
pure virtual

This is thread safe by default. the option can change to thread unsafe in order to accelerate.

  • Must be careful when use this.
virtual void Proud::CLookasideAllocator::Free ( void *  ptr)
pure virtual

Disengage the allocated memory.

static CLookasideAllocator* Proud::CLookasideAllocator::New ( const CFastHeapSettings settings = CFastHeapSettings())
static

Creates a new Lookaside allocator

Parameters
settingsCan set the initial attributes. This is a neglectable parameter.