Support Forum G3D Web Page |
Allocates memory in large blocks and then frees it as an area.
More...
Inherits G3D::MemoryManager.
Public Member Functions | |
~AreaMemoryManager () | |
Invokes deallocateAll. More... | |
virtual void * | alloc (size_t s) |
Allocates memory out of the buffer pool. More... | |
size_t | bytesAllocated () const |
void | deallocateAll () |
Deletes all previously allocated memory. More... | |
virtual void | free (void *x) |
Ignored. More... | |
virtual bool | isThreadsafe () const |
Returns true if this memory manager is threadsafe (i.e., alloc and free can be called asychronously) More... | |
Static Public Member Functions | |
static shared_ptr< MemoryManager > | create () |
Return the instance. More... | |
static shared_ptr< AreaMemoryManager > | create (size_t sizeHint=10 *1024 *1024) |
Static Protected Member Functions | |
template<class T , class ... ArgTypes> | |
static shared_ptr< T > | createShared (ArgTypes &&... args) |
Like std::make_shared, but works for protected constructors. More... | |
Allocates memory in large blocks and then frees it as an area.
Useful for ensuring cache coherence and for reducing the time cost of multiple allocations and deallocations.
Not threadsafe
G3D::AreaMemoryManager::~AreaMemoryManager | ( | ) |
Invokes deallocateAll.
|
virtual |
Allocates memory out of the buffer pool.
s | must be no larger than sizeHint |
Reimplemented from G3D::MemoryManager.
size_t G3D::AreaMemoryManager::bytesAllocated | ( | ) | const |
|
staticinherited |
Return the instance.
There's only one instance of the default MemoryManager; it is cached after the first creation.
Referenced by G3D::Array< G3D::AABox >::Array(), G3D::categorizeByDerivedType(), and G3D::Table< String, double >::Table().
|
static |
sizeHint | Total amount of memory expected to be allocated. The allocator will allocate memory from the system in increments of this size. |
|
inlinestaticprotectedinherited |
Like std::make_shared, but works for protected constructors.
Call as createShared<myclass>.
void G3D::AreaMemoryManager::deallocateAll | ( | ) |
Deletes all previously allocated memory.
Because delete is not invoked on objects in this memory, it is not safe to simply free memory containing C++ objects that expect their destructors to be called.
|
virtual |
Ignored.
Reimplemented from G3D::MemoryManager.
|
virtual |
Returns true if this memory manager is threadsafe (i.e., alloc and free can be called asychronously)
Reimplemented from G3D::MemoryManager.