Support Forum       G3D Web Page     
Classes | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | List of all members
G3D::AreaMemoryManager Class Reference


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< MemoryManagercreate ()
 Return the instance. More...
 
static shared_ptr< AreaMemoryManagercreate (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...
 

Detailed Description


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

Constructor & Destructor Documentation

◆ ~AreaMemoryManager()

G3D::AreaMemoryManager::~AreaMemoryManager ( )

Invokes deallocateAll.

Member Function Documentation

◆ alloc()

virtual void* G3D::AreaMemoryManager::alloc ( size_t  s)
virtual

Allocates memory out of the buffer pool.

Parameters
smust be no larger than sizeHint

Reimplemented from G3D::MemoryManager.

◆ bytesAllocated()

size_t G3D::AreaMemoryManager::bytesAllocated ( ) const

◆ create() [1/2]

static shared_ptr<MemoryManager> G3D::MemoryManager::create ( )
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().

◆ create() [2/2]

static shared_ptr<AreaMemoryManager> G3D::AreaMemoryManager::create ( size_t  sizeHint = 10 *1024 *1024)
static
Parameters
sizeHintTotal amount of memory expected to be allocated. The allocator will allocate memory from the system in increments of this size.

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ deallocateAll()

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.

◆ free()

virtual void G3D::AreaMemoryManager::free ( void *  x)
virtual

Ignored.

Reimplemented from G3D::MemoryManager.

◆ isThreadsafe()

virtual bool G3D::AreaMemoryManager::isThreadsafe ( ) const
virtual

Returns true if this memory manager is threadsafe (i.e., alloc and free can be called asychronously)

Reimplemented from G3D::MemoryManager.


documentation generated on Wed Nov 24 2021 08:01:53 using doxygen 1.8.15