DART 6.13.2
|
A composite memory allocator that contains various memory allocators that are optimized for different use cases. More...
#include <MemoryManager.hpp>
Public Types | |
enum class | Type { Base , Free , Pool } |
Type of the memory allocators. More... | |
Public Member Functions | |
MemoryManager (MemoryAllocator &baseAllocator=MemoryAllocator::GetDefault()) | |
Constructor. | |
~MemoryManager () | |
Destructor. | |
MemoryAllocator & | getBaseAllocator () |
Returns the base allocator. | |
FreeListAllocator & | getFreeListAllocator () |
Returns the free list allocator. | |
PoolAllocator & | getPoolAllocator () |
Returns the pool allocator. | |
void * | allocate (Type type, size_t bytes) |
Allocates size bytes of uninitialized storage. | |
void * | allocateUsingFree (size_t bytes) |
Allocates size bytes of uninitialized storage using FreeListAllocator. | |
void * | allocateUsingPool (size_t bytes) |
Allocates size bytes of uninitialized storage using PoolAllocator. | |
void | deallocate (Type type, void *pointer, size_t bytes) |
Deallocates the storage referenced by the pointer p , which must be a pointer obtained by an earlier cal to allocate(). | |
void | deallocateUsingFree (void *pointer, size_t bytes) |
void | deallocateUsingPool (void *pointer, size_t bytes) |
template<typename T , typename... Args> | |
T * | construct (Type type, Args &&... args) noexcept |
Allocates uninitialized storage and constructs an object of type T to the allocated storage. | |
template<typename T , typename... Args> | |
T * | constructUsingFree (Args &&... args) noexcept |
Allocates uninitialized storage using FreeListAllocator and constructs an object of type T to the allocated storage. | |
template<typename T , typename... Args> | |
T * | constructUsingPool (Args &&... args) noexcept |
Allocates uninitialized storage using PoolAllocator and constructs an object of type T to the allocated storage. | |
template<typename T > | |
void | destroy (Type type, T *object) noexcept |
Calls the destructor of the object and deallocate the storage. | |
template<typename T > | |
void | destroyUsingFree (T *pointer) noexcept |
Calls the destructor of the object and deallocate the storage using FreeListAllocator. | |
template<typename T > | |
void | destroyUsingPool (T *pointer) noexcept |
Calls the destructor of the object and deallocate the storage using PoolAllocator. | |
bool | hasAllocated (void *pointer, size_t size) const noexcept |
Returns true if a pointer is allocated by the internal allocator. | |
void | print (std::ostream &os=std::cout, int indent=0) const |
Prints state of the memory manager. | |
Static Public Member Functions | |
static MemoryManager & | GetDefault () |
Returns the default memory manager. | |
Private Attributes | |
MemoryAllocator & | mBaseAllocator |
The base allocator to allocate memory chunck. | |
FreeListAllocator::Debug | mFreeListAllocator |
The free list allocator. | |
PoolAllocator::Debug | mPoolAllocator |
The pool allocator. | |
Friends | |
std::ostream & | operator<< (std::ostream &os, const MemoryManager &memoryManager) |
Prints state of the memory manager. | |
A composite memory allocator that contains various memory allocators that are optimized for different use cases.
|
strong |
|
explicit |
Constructor.
[in] | baseAllocator | (optional) The most low level allocator to be used by all the underlying memory allocators. |
dart::common::MemoryManager::~MemoryManager | ( | ) |
Destructor.
void * dart::common::MemoryManager::allocate | ( | Type | type, |
size_t | bytes | ||
) |
Allocates size
bytes of uninitialized storage.
[in] | type | The memory allocator type. |
[in] | bytes | The byte size to allocate sotrage for. |
void * dart::common::MemoryManager::allocateUsingFree | ( | size_t | bytes | ) |
Allocates size
bytes of uninitialized storage using FreeListAllocator.
[in] | bytes | The byte size to allocate sotrage for. |
void * dart::common::MemoryManager::allocateUsingPool | ( | size_t | bytes | ) |
Allocates size
bytes of uninitialized storage using PoolAllocator.
[in] | bytes | The byte size to allocate sotrage for. |
|
noexcept |
Allocates uninitialized storage and constructs an object of type T to the allocated storage.
T | The object type to construct. |
Args... | The argument types to pass to the object constructor. |
[in] | type | The memory allocator type. |
[in] | args | The constructor arguments to use. |
|
noexcept |
Allocates uninitialized storage using FreeListAllocator and constructs an object of type T to the allocated storage.
|
noexcept |
Allocates uninitialized storage using PoolAllocator and constructs an object of type T to the allocated storage.
void dart::common::MemoryManager::deallocate | ( | Type | type, |
void * | pointer, | ||
size_t | bytes | ||
) |
Deallocates the storage referenced by the pointer p
, which must be a pointer obtained by an earlier cal to allocate().
[in] | type | The memory allocator type. |
[in] | pointer | Pointer obtained from allocate(). |
[in] | bytes | The bytes of the allocated memory. |
void dart::common::MemoryManager::deallocateUsingFree | ( | void * | pointer, |
size_t | bytes | ||
) |
void dart::common::MemoryManager::deallocateUsingPool | ( | void * | pointer, |
size_t | bytes | ||
) |
|
noexcept |
Calls the destructor of the object and deallocate the storage.
|
noexcept |
Calls the destructor of the object and deallocate the storage using FreeListAllocator.
|
noexcept |
Calls the destructor of the object and deallocate the storage using PoolAllocator.
MemoryAllocator & dart::common::MemoryManager::getBaseAllocator | ( | ) |
Returns the base allocator.
|
static |
Returns the default memory manager.
FreeListAllocator & dart::common::MemoryManager::getFreeListAllocator | ( | ) |
Returns the free list allocator.
PoolAllocator & dart::common::MemoryManager::getPoolAllocator | ( | ) |
Returns the pool allocator.
|
noexcept |
Returns true if a pointer is allocated by the internal allocator.
void dart::common::MemoryManager::print | ( | std::ostream & | os = std::cout , |
int | indent = 0 |
||
) | const |
Prints state of the memory manager.
|
friend |
Prints state of the memory manager.
|
private |
The base allocator to allocate memory chunck.
|
private |
The free list allocator.
|
private |
The pool allocator.