 |
|
 |
 |
Documentation |
|
Main Page Namespace List Class Hierarchy Alphabetical List Compound List File List Namespace Members Compound Members File Members Related Pages Search
NLMEMORY::CHeapAllocator Class Reference#include <heap_allocator.h>
List of all members.
Public Types |
| enum | TBlockAllocationMode { Grow,
DontGrow
} |
| | Block allocation mode. More...
|
| enum | TOutOfMemoryMode { ThrowException,
ReturnNull
} |
| | Out of memory signal. More...
|
| enum | {
SmallBlockGranularityShift = 3,
SmallBlockGranularity = 1<<SmallBlockGranularityShift,
FirstSmallBlock = 8,
LastSmallBlock = 128,
SmallBlockPoolSize = 20
} |
Public Methods |
| | CHeapAllocator (uint mainBlockSize=1024 *1024 *10, uint blockCount=1, TBlockAllocationMode blockAllocationMode=Grow, TOutOfMemoryMode outOfMemoryMode=ThrowException) |
| | Constructor / Destructor. More...
|
| | ~CHeapAllocator () |
| | Destruction. More...
|
| void | free (void *ptr) |
| | Free a pointer. More...
|
| void | freeAll () |
| | Free all the block allocated. More...
|
| void | releaseMemory () |
| bool | setMainBlockSize (uint mainBlockSize) |
| | Returns false if the block size choosed i too big (>= 1 Go). More...
|
| uint | getMainBlockSize () const |
| | Get the size of the block. More...
|
| bool | setMainBlockCount (uint blockCount) |
| | Set the block count. More...
|
| uint | getMainBlockCount () const |
| | Get the block count. More...
|
| void | setBlockAllocationMode (TBlockAllocationMode mode) |
| TBlockAllocationMode | getBlockAllocationMode () const |
| void | setOutOfMemoryMode (TOutOfMemoryMode mode) |
| TOutOfMemoryMode | getOutOfMemoryMode () const |
| bool | checkHeap (bool stopOnError) const |
| uint | getAllocatedMemory () const |
| uint | getFreeMemory () const |
| uint | getTotalMemoryUsed () const |
| uint | getSmallBlockMemory () const |
| uint | getAllocatedSystemMemoryByAllocator () |
| float | getFragmentationRatio () const |
| void | setName (const char *name) |
| const char * | getName () const |
| uint | debugGetDebugInfoSize () const |
| uint | debugGetSBDebugInfoSize () const |
| uint | debugGetLBDebugInfoSize () const |
| uint | debugGetAllocatedMemoryByCategory (const char *category) const |
| bool | debugStatisticsReport (const char *stateFile, bool memoryMap) |
| void | debugAlwaysCheckMemory (bool alwaysCheck) |
| bool | debugIsAlwaysCheckMemory (bool alwaysCheck) const |
| void | debugReportMemoryLeak () |
| virtual uint8 * | allocateBlock (uint size) |
| | Method used to allocate system memory. More...
|
| virtual void | freeBlock (uint8 *block) |
| | Method used to free system memory. More...
|
| void * | allocate (uint size, const char *sourceFile, uint line, const char *category) |
| void * | reallocate (void *ptr, uint size, const char *sourceFile, uint line, const char *category) |
| void | debugPushCategoryString (const char *str) |
| void | debugPopCategoryString () |
Static Public Methods |
| uint | getBlockSize (void *block) |
| | Get a block size with its pointer. More...
|
| uint | getAllocatedSystemMemory () |
Private Types |
| typedef char | TCategoryString [CategoryStringLength] |
| enum | {
ReleaseHeaderSize = 8,
CategoryStringLength = 8,
BeginNodeMarkers = '<',
EndNodeMarkers = '>',
UnallocatedMemory = 0xba,
UninitializedMemory = 0xbc,
DeletedMemory = 0xbd,
NameLength = 32
} |
| enum | { FreeNodeBlockSize = 128,
FreeNodeBlockSizeShift = 7,
FreeNodeBlockSizeMask = 0x7f
} |
| enum | { Align = 8,
BlockDataSizeMin = 1<<4
} |
| enum | { UserDataBlockSizeMin = sizeof(CFreeNode)
} |
Private Methods |
| bool | checkNodeLB (const CMainBlock *mainBlock, const CNodeBegin *previous, const CNodeBegin *current, const CNodeBegin *next, bool stopOnError) const |
| void | rotateLeft (CFreeNode *x) |
| void | rotateRight (CFreeNode *x) |
| void | insert (CFreeNode *x) |
| void | erase (CFreeNode *z) |
| CFreeNode * | find (uint size) |
| CNodeBegin * | splitNode (CNodeBegin *node, uint newSize) |
| void | initEmptyBlock (CMainBlock &mainBlock) |
| bool | checkFreeNode (const CFreeNode *current, bool stopOnError, bool recurse) const |
| void | checkNode (const CNodeBegin *current, uint32 crc) const |
| bool | internalCheckHeap (bool stopOnError) const |
| void | enterCriticalSection () const |
| void | leaveCriticalSection () const |
| void | enterCriticalSectionSB () const |
| void | leaveCriticalSectionSB () const |
| void | enterCriticalSectionLB () const |
| void | leaveCriticalSectionLB () const |
| bool | checkNodeSB (const CSmallBlockPool *mainBlock, const CNodeBegin *previous, const CNodeBegin *current, const CNodeBegin *next, bool stopOnError) const |
Static Private Methods |
| uint32 | evalMagicNumber (const CNodeBegin *node) |
| const CNodeBegin * | getNextNode (const CNodeBegin *current) |
| CNodeBegin * | getNextNode (CNodeBegin *current) |
| const CFreeNode * | getFreeNode (const CNodeBegin *current) |
| CFreeNode * | getFreeNode (CNodeBegin *current) |
| const CNodeBegin * | getNode (const CFreeNode *current) |
| CNodeBegin * | getNode (CFreeNode *current) |
| uint | getNodeSize (const CNodeBegin *current) |
| bool | isNodeFree (const CNodeBegin *current) |
| bool | isNodeUsed (const CNodeBegin *current) |
| bool | isNodeLast (const CNodeBegin *current) |
| bool | isNodeSmall (const CNodeBegin *current) |
| bool | isNodeRed (const CFreeNode *current) |
| bool | isNodeBlack (const CFreeNode *current) |
| void | setNodeFree (CNodeBegin *current) |
| void | setNodeUsed (CNodeBegin *current) |
| void | setNodeLast (CNodeBegin *current, bool last) |
| void | setNodeSize (CNodeBegin *current, uint size) |
| void | setNodeColor (CFreeNode *current, bool red) |
| void | setNodeRed (CFreeNode *current) |
| void | setNodeBlack (CFreeNode *current) |
| const CNodeBegin * | getFirstNode (const CMainBlock *mainBlock) |
| CNodeBegin * | getFirstNode (CMainBlock *mainBlock) |
| void | mergeNode (CNodeBegin *node) |
| void | computeCRC32 (uint32 &crc, const void *buffer, unsigned int count) |
| CNodeBegin * | getSmallBlock (CSmallBlockPool *smallBlock, uint blockIndex) |
| CNodeBegin * | getNextSmallBlock (CNodeBegin *previous) |
| void | setNextSmallBlock (CNodeBegin *previous, CNodeBegin *next) |
Private Attributes |
| uint | _MainBlockSize |
| uint | _BlockCount |
| TBlockAllocationMode | _BlockAllocationMode |
| TOutOfMemoryMode | _OutOfMemoryMode |
| bool | _AlwaysCheck |
| CMainBlock * | _MainBlockList |
| CFreeNode * | _FreeTreeRoot |
| CNullNode | _NullNode |
| CMemoryMutex | _MutexLB |
| char | _Name [NameLength] |
| uint32 | _AllocateCount |
| volatile CNodeBegin * | _FreeSmallBlocks [NL_SMALLBLOCK_COUNT] |
| volatile CSmallBlockPool * | _SmallBlockPool |
| CMemoryMutex | _MutexSB |
| CMemoryTDS | _CategoryStack |
Friends |
| struct | CNodeBegin |
Member Typedef Documentation
typedef char NLMEMORY::CHeapAllocator::TCategoryString[CategoryStringLength] [private]
|
|
Member Enumeration Documentation
|
|
-
Enumeration values:
-
| ReleaseHeaderSize |
|
| CategoryStringLength |
|
| BeginNodeMarkers |
|
| EndNodeMarkers |
|
| UnallocatedMemory |
|
| UninitializedMemory |
|
| DeletedMemory |
|
| NameLength |
|
Definition at line 202 of file src/memory/heap_allocator.h. |
|
|
-
Enumeration values:
-
| SmallBlockGranularityShift |
|
| SmallBlockGranularity |
|
| FirstSmallBlock |
|
| LastSmallBlock |
|
| SmallBlockPoolSize |
|
Definition at line 446 of file src/memory/heap_allocator.h. |
| enum NLMEMORY::CHeapAllocator::TBlockAllocationMode
|
|
|
|
Block allocation mode.
-
Enumeration values:
-
| Grow |
When the allocator runs out of memory, allocate a new block. |
| DontGrow |
When the allocator runs out of memory, returns a out of memory signal. |
Definition at line 72 of file src/memory/heap_allocator.h. |
| enum NLMEMORY::CHeapAllocator::TOutOfMemoryMode
|
|
|
|
Out of memory signal.
-
Enumeration values:
-
| ThrowException |
When the allocator runs out of memory, throw an exception. |
| ReturnNull |
When the allocator runs out of memory, returns NULL. |
Definition at line 84 of file src/memory/heap_allocator.h. |
Constructor & Destructor Documentation
| NLMEMORY::CHeapAllocator::~CHeapAllocator |
( |
|
) |
|
|
Member Function Documentation
| void * NLMEMORY::CHeapAllocator::allocate |
( |
uint |
size, |
|
|
const char * |
sourceFile, |
|
|
uint |
line, |
|
|
const char * |
category |
|
) |
|
|
| uint8 * NLMEMORY::CHeapAllocator::allocateBlock |
( |
uint |
size |
) |
[virtual] |
|
| bool NLMEMORY::CHeapAllocator::checkFreeNode |
( |
const CFreeNode * |
current, |
|
|
bool |
stopOnError, |
|
|
bool |
recurse |
|
) |
const [inline, private] |
|
| bool NLMEMORY::CHeapAllocator::checkHeap |
( |
bool |
stopOnError |
) |
const |
|
| void NLMEMORY::CHeapAllocator::checkNode |
( |
const CNodeBegin * |
current, |
|
|
uint32 |
crc |
|
) |
const [private] |
|
| void NLMEMORY::CHeapAllocator::computeCRC32 |
( |
uint32 & |
crc, |
|
|
const void * |
buffer, |
|
|
unsigned int |
count |
|
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::debugAlwaysCheckMemory |
( |
bool |
alwaysCheck |
) |
|
|
| uint NLMEMORY::CHeapAllocator::debugGetAllocatedMemoryByCategory |
( |
const char * |
category |
) |
const |
|
|
|
Definition at line 2122 of file memory/heap_allocator.cpp.
References _MainBlockList, _SmallBlockPool, checkNodeLB, checkNodeSB, CNodeBegin, enterCriticalSection, getFirstNode, getNextNode, getSmallBlock, internalAssert, and SmallBlockPoolSize. |
| uint NLMEMORY::CHeapAllocator::debugGetDebugInfoSize |
( |
|
) |
const |
|
| uint NLMEMORY::CHeapAllocator::debugGetLBDebugInfoSize |
( |
|
) |
const |
|
| uint NLMEMORY::CHeapAllocator::debugGetSBDebugInfoSize |
( |
|
) |
const |
|
| bool NLMEMORY::CHeapAllocator::debugIsAlwaysCheckMemory |
( |
bool |
alwaysCheck |
) |
const |
|
| void NLMEMORY::CHeapAllocator::debugPopCategoryString |
( |
|
) |
|
|
| void NLMEMORY::CHeapAllocator::debugPushCategoryString |
( |
const char * |
str |
) |
|
|
| void NLMEMORY::CHeapAllocator::debugReportMemoryLeak |
( |
|
) |
|
|
| bool NLMEMORY::CHeapAllocator::debugStatisticsReport |
( |
const char * |
stateFile, |
|
|
bool |
memoryMap |
|
) |
|
|
| void NLMEMORY::CHeapAllocator::enterCriticalSection |
( |
|
) |
const [inline, private] |
|
| void NLMEMORY::CHeapAllocator::enterCriticalSectionLB |
( |
|
) |
const [inline, private] |
|
| void NLMEMORY::CHeapAllocator::enterCriticalSectionSB |
( |
|
) |
const [inline, private] |
|
| void NLMEMORY::CHeapAllocator::erase |
( |
CFreeNode * |
z |
) |
[inline, private] |
|
| uint32 NLMEMORY::CHeapAllocator::evalMagicNumber |
( |
const CNodeBegin * |
node |
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::free |
( |
void * |
ptr |
) |
|
|
| void NLMEMORY::CHeapAllocator::freeAll |
( |
|
) |
|
|
| void NLMEMORY::CHeapAllocator::freeBlock |
( |
uint8 * |
block |
) |
[virtual] |
|
| uint NLMEMORY::CHeapAllocator::getAllocatedMemory |
( |
|
) |
const |
|
| uint NLMEMORY::CHeapAllocator::getAllocatedSystemMemory |
( |
|
) |
[static] |
|
| uint NLMEMORY::CHeapAllocator::getAllocatedSystemMemoryByAllocator |
( |
|
) |
|
|
| uint NLMEMORY::CHeapAllocator::getBlockSize |
( |
void * |
block |
) |
[static] |
|
| float NLMEMORY::CHeapAllocator::getFragmentationRatio |
( |
|
) |
const |
|
| uint NLMEMORY::CHeapAllocator::getFreeMemory |
( |
|
) |
const |
|
| uint NLMEMORY::CHeapAllocator::getMainBlockCount |
( |
|
) |
const [inline] |
|
| uint NLMEMORY::CHeapAllocator::getMainBlockSize |
( |
|
) |
const [inline] |
|
| const char * NLMEMORY::CHeapAllocator::getName |
( |
|
) |
const [inline] |
|
| uint NLMEMORY::CHeapAllocator::getNodeSize |
( |
const CNodeBegin * |
current |
) |
[inline, static, private] |
|
| uint NLMEMORY::CHeapAllocator::getSmallBlockMemory |
( |
|
) |
const |
|
| uint NLMEMORY::CHeapAllocator::getTotalMemoryUsed |
( |
|
) |
const |
|
| void NLMEMORY::CHeapAllocator::initEmptyBlock |
( |
CMainBlock & |
mainBlock |
) |
[inline, private] |
|
| void NLMEMORY::CHeapAllocator::insert |
( |
CFreeNode * |
x |
) |
[inline, private] |
|
| bool NLMEMORY::CHeapAllocator::internalCheckHeap |
( |
bool |
stopOnError |
) |
const [private] |
|
| bool NLMEMORY::CHeapAllocator::isNodeBlack |
( |
const CFreeNode * |
current |
) |
[inline, static, private] |
|
| bool NLMEMORY::CHeapAllocator::isNodeFree |
( |
const CNodeBegin * |
current |
) |
[inline, static, private] |
|
| bool NLMEMORY::CHeapAllocator::isNodeLast |
( |
const CNodeBegin * |
current |
) |
[inline, static, private] |
|
| bool NLMEMORY::CHeapAllocator::isNodeRed |
( |
const CFreeNode * |
current |
) |
[inline, static, private] |
|
| bool NLMEMORY::CHeapAllocator::isNodeSmall |
( |
const CNodeBegin * |
current |
) |
[inline, static, private] |
|
| bool NLMEMORY::CHeapAllocator::isNodeUsed |
( |
const CNodeBegin * |
current |
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::leaveCriticalSection |
( |
|
) |
const [inline, private] |
|
| void NLMEMORY::CHeapAllocator::leaveCriticalSectionLB |
( |
|
) |
const [inline, private] |
|
| void NLMEMORY::CHeapAllocator::leaveCriticalSectionSB |
( |
|
) |
const [inline, private] |
|
| void NLMEMORY::CHeapAllocator::mergeNode |
( |
CNodeBegin * |
node |
) |
[inline, static, private] |
|
| void* NLMEMORY::CHeapAllocator::reallocate |
( |
void * |
ptr, |
|
|
uint |
size, |
|
|
const char * |
sourceFile, |
|
|
uint |
line, |
|
|
const char * |
category |
|
) |
|
|
| void NLMEMORY::CHeapAllocator::releaseMemory |
( |
|
) |
|
|
| void NLMEMORY::CHeapAllocator::rotateLeft |
( |
CFreeNode * |
x |
) |
[inline, private] |
|
| void NLMEMORY::CHeapAllocator::rotateRight |
( |
CFreeNode * |
x |
) |
[inline, private] |
|
| bool NLMEMORY::CHeapAllocator::setMainBlockCount |
( |
uint |
blockCount |
) |
|
|
| bool NLMEMORY::CHeapAllocator::setMainBlockSize |
( |
uint |
mainBlockSize |
) |
|
|
|
|
Returns false if the block size choosed i too big (>= 1 Go).
|
| void NLMEMORY::CHeapAllocator::setName |
( |
const char * |
name |
) |
|
|
| void NLMEMORY::CHeapAllocator::setNextSmallBlock |
( |
CNodeBegin * |
previous, |
|
|
CNodeBegin * |
next |
|
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::setNodeBlack |
( |
CFreeNode * |
current |
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::setNodeColor |
( |
CFreeNode * |
current, |
|
|
bool |
red |
|
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::setNodeFree |
( |
CNodeBegin * |
current |
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::setNodeLast |
( |
CNodeBegin * |
current, |
|
|
bool |
last |
|
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::setNodeRed |
( |
CFreeNode * |
current |
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::setNodeSize |
( |
CNodeBegin * |
current, |
|
|
uint |
size |
|
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::setNodeUsed |
( |
CNodeBegin * |
current |
) |
[inline, static, private] |
|
| void NLMEMORY::CHeapAllocator::setOutOfMemoryMode |
( |
TOutOfMemoryMode |
mode |
) |
[inline] |
|
Friends And Related Function Documentation
friend struct CNodeBegin [friend]
|
|
Member Data Documentation
uint32 NLMEMORY::CHeapAllocator::_AllocateCount [private]
|
|
bool NLMEMORY::CHeapAllocator::_AlwaysCheck [private]
|
|
uint NLMEMORY::CHeapAllocator::_BlockCount [private]
|
|
CMemoryTDS NLMEMORY::CHeapAllocator::_CategoryStack [private]
|
|
volatile CNodeBegin* NLMEMORY::CHeapAllocator::_FreeSmallBlocks[NL_SMALLBLOCK_COUNT] [private]
|
|
CFreeNode* NLMEMORY::CHeapAllocator::_FreeTreeRoot [private]
|
|
CMainBlock* NLMEMORY::CHeapAllocator::_MainBlockList [private]
|
|
uint NLMEMORY::CHeapAllocator::_MainBlockSize [private]
|
|
char NLMEMORY::CHeapAllocator::_Name[NameLength] [private]
|
|
CNullNode NLMEMORY::CHeapAllocator::_NullNode [private]
|
|
volatile CSmallBlockPool* NLMEMORY::CHeapAllocator::_SmallBlockPool [private]
|
|
The documentation for this class was generated from the following files:
|
 |