gatb.core-API-0.0.0
|
Implementation of IMemory interface with Proxy design pattern. More...
#include <MemoryCommon.hpp>
Public Member Functions | |
MemorySizeStore (IMemoryAllocator &alloc) | |
void * | malloc (BlockSize_t size) |
void * | calloc (size_t nmemb, BlockSize_t size) |
void * | realloc (void *ptr, BlockSize_t size) |
void | free (void *ptr) |
size_t | getNbBlocks () |
TotalSize_t | getCurrentUsage () |
TotalSize_t | getMaximumUsage () |
Public Member Functions inherited from IMemoryAllocator | |
virtual | ~IMemoryAllocator () |
Additional Inherited Members | |
Public Types inherited from IMemoryAllocator | |
typedef u_int64_t | BlockSize_t |
typedef u_int64_t | TotalSize_t |
Implementation of IMemory interface with Proxy design pattern.
This implementation is a Proxy design pattern: it references a memory allocator and uses this reference for creating memory blocks.
Statistics operations are provided through the IMemory interface. Providing such services implies that we have some management of the allocated blocks. In particular we need to store the size of block which is done by allocating some extra space for each block (this space being used for storing the block size).
Note that such an implementation requires a little bit more memory than clients actually ask for: for instance, if a client calls malloc with 100, the final allocated block size will be 100+4=104 bytes (if sizeof(BlockSize_t)==4).
It is mandatory that blocks created through this implementation are also deleted by the same implementation.
|
inline |
Constructor.
[in] | alloc | : the referred memory allocator. |
|
inlinevirtual |
|
inlinevirtual |
|
inline |
Get the memory usage by the current process.
|
inline |
Get the maximum reached size.
|
inline |
Get the number of currently allocated memory blocks.
|
inlinevirtual |
|
inlinevirtual |