An application heap. More...
#include <MemoryPool.h>
Public Member Functions | |
| MemoryPool (const int blockSize=DEFAULT_MEMORY_POOL_BLOCK_SIZE, bool bSetMemoryData=false) | |
| void * | Malloc (int size) |
| void | Free (void *ptr) |
| bool | WriteMemoryDumpToFile (const char *fileName) const |
| bool | IsValidPointer (const void *ptr) const |
| virtual void | ValidateMem () const |
| virtual void | CheckMem () const |
An application heap.
This class is the actual implementation of the IMemoryBlock - Interface. It is responsible for all MemoryRequests (GetMemory() / FreeMemory()) and manages the allocation/deallocation of Memory from the Operating-System.
Definition at line 58 of file MemoryPool.h.
| MemoryPool::MemoryPool | ( | const int | blockSize = DEFAULT_MEMORY_POOL_BLOCK_SIZE, |
|
| bool | bSetMemoryData = false | |||
| ) |
Contructor
| [IN] | blockSize The Size (in Bytes) each MemoryChunk can Manage. A low sMemoryChunkSize increases the MemoryPool runtime (bad), but decreases the Memory-overhead/fragmentation (good) | |
| [IN] | bSetMemoryData Set to true, if you want to set all allocated/freed Memory to a specific Value. Very usefull for debugging, but has a negativ impact on the runtime. |
Definition at line 26 of file MemoryPool.cpp.
References MemoryBlock::m_data, MemoryBlock::m_next, MemoryBlock::m_pos, and MemoryBlock::m_size.
| void MemoryPool::Free | ( | void * | ptr | ) |
Free the allocated memory again....
| [IN] | ptrMemoryBlock Pointer to a Block of Memory, which is to be freed (previoulsy allocated via "GetMemory()"). | |
| [IN] | sMemorySize Sizes (in Bytes) of Memory. |
Definition at line 104 of file MemoryPool.cpp.
References MemoryBlock::m_blockId, MemoryBlock::m_freeSize, MemoryBlock::m_next, MemoryBlock::m_pos, and MemoryBlock::m_size.
| bool MemoryPool::IsValidPointer | ( | const void * | ptr | ) | const |
Check, if a Pointer is in the Memory-Pool. Note : This Checks only if a pointer is inside the Memory-Pool, and not if the Memory contains meaningfull data.
| [IN] | ptrPointer Pointer to a Memory-Block which is to be checked. |
Definition at line 147 of file MemoryPool.cpp.
References MemoryBlock::m_blockId, and MemoryBlock::m_next.
| void * MemoryPool::Malloc | ( | int | size | ) |
Get "sMemorySize" Bytes from the Memory Pool.
| [IN] | sMemorySize Sizes (in Bytes) of Memory. |
Definition at line 60 of file MemoryPool.cpp.
References MemoryBlock::m_blockId, MemoryBlock::m_data, MemoryBlock::m_next, MemoryBlock::m_pos, and MemoryBlock::m_size.
| bool MemoryPool::WriteMemoryDumpToFile | ( | const char * | fileName | ) | const |
Writes the contents of the MemoryPool to a File. Note : This file can be quite large (several MB).
| [IN] | strFileName FileName of the MemoryDump. |
Definition at line 131 of file MemoryPool.cpp.
References MemoryBlock::m_data, MemoryBlock::m_next, and MemoryBlock::m_size.