gatb.core-API-0.0.0
|
Implementation of IMemory interface with bounded memory usage. More...
#include <MemoryCommon.hpp>
Public Member Functions | |
MemoryBounded (IMemoryAllocator &alloc, BlockSize_t maxBlockSize, TotalSize_t maxTotalSize) | |
void * | malloc (BlockSize_t size) |
void * | calloc (size_t nmemb, BlockSize_t size) |
void * | realloc (void *ptr, BlockSize_t size) |
void | free (void *ptr) |
Public Member Functions inherited from MemorySizeStore | |
MemorySizeStore (IMemoryAllocator &alloc) | |
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 bounded memory usage.
This implementation is a Proxy design pattern: it references a memory allocator and checks that client requests doesn't exceed this kind of specifications. If the client request is allowed, the request is done by the referred allocator.
Two thresholds can be parameterize such an allocator at construction:
Implementation note: in order to ensure that the thresholds are not exceeded, we need to know the size of each allocated pointer. Therefore, when allocating some block of size N, we actually allocate N+d bytes, where d is the size of an integer big enough to represent the requested block size. This size is provided through the class template T.
|
inline |
Constructor.
[in] | alloc | : the referred IMemoryAllocator instance |
[in] | maxBlockSize | : maximum size allowed for one block allocation |
[in] | maxTotalSize | : maximum size allowed for the sum of blocks allocation |
|
inlinevirtual |
See calloc documentation.
Reimplemented from MemorySizeStore.
|
inlinevirtual |
See free documentation.
Reimplemented from MemorySizeStore.
|
inlinevirtual |
See malloc documentation.
Reimplemented from MemorySizeStore.
|
inlinevirtual |
See realloc documentation.
Reimplemented from MemorySizeStore.