Proud::CFastHeap Class Referenceabstract

Public Types

enum  { DefaultAccelBlockSizeLimit = 2048 }
 

Public Member Functions

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

Static Public Member Functions

static PROUD_API CFastHeapNew (size_t AccelBlockSizeLimit=DefaultAccelBlockSizeLimit, const CFastHeapSettings &settings=CFastHeapSettings())
 
static PROUD_API void AssureValidBlock (void *block)
 

Detailed Description

Though this allocation class allocates heap alloc with high speed but there are some restrictions.

Usage

Strength

  • High allocation speed

Weakness

  • The instance allocated by this allocator must be destructed before main() terminates. In other words, must be carefu when set this as global variable.
  • A certain size or bigger cannot be accelerated.
  • This leaves some unused memory when used for a long time since this is memory pool way. Therefore, this can be used only when there are needs to perform frequent allocation/destruction.

Member Function Documentation

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

TODO:translate needed. Allocates memory. The allocated memory can be balalnced to either Realloc or Free.

static PROUD_API void Proud::CFastHeap::AssureValidBlock ( void *  block)
static

If block is not created by fast heap then it will either produce an error window or cause a crash.

virtual void Proud::CFastHeap::Free ( void *  ptr)
pure virtual

TODO:translate needed. Disengages allocated memory

static PROUD_API CFastHeap* Proud::CFastHeap::New ( size_t  AccelBlockSizeLimit = DefaultAccelBlockSizeLimit,
const CFastHeapSettings settings = CFastHeapSettings() 
)
static

Creates CFastHeap object

Parameters
AccelBlockSizeLimitWhenever allocating memory block bigger than this value, this allocates a usual memory block that does not follow lookaside allocator. Bigger this value becomes, occupies more memory but also increased chance of high speed heap allocation probability. (But if it is too bug then it lowers performance due to page fault cost.)
pHeapIn order to let this Fast Heap use other Heap that is not previously created by ProudNet, CMemoryHeap object pointer must be entered in here. But, this class does not automatically remove CMemoryHeap. If NULL is entered in here then uses previously created Heap by ProudNet.
safeModePlease refer CLookasideAllocator.New()
debugSafetyCheckCritSecfor debugging use. Only valid when safeMode=false Whenever access to this fast heap, must check if critical section pointed by debugSafetyCheckCritSec is in its locked status by current thread, if not locked then this alarms that error occurs.
virtual void* Proud::CFastHeap::Realloc ( void *  ptr,
size_t  size 
)
pure virtual

TODO:translate needed. Re-allocates memory. Must refer the returned pointer value since re-allocated memory can change its location.