AGX Dynamics 2.42.3.1
Loading...
Searching...
No Matches
agx::MemoryPoolOld< T > Class Template Reference

#include <MemoryPool.h>

+ Inheritance diagram for agx::MemoryPoolOld< T >:

Public Member Functions

 MemoryPoolOld (size_t initialSize=0, size_t chunkSize=64)
 
 ~MemoryPoolOld ()
 
T * acquire ()
 
size_t capacity () const
 \ return the total number of elements allocated
 
void clear ()
 Clear all memory allocated by this MemoryPoolOld.
 
void flush ()
 Return all elements to container.
 
void garbageCollect ()
 Free memory not in use.
 
int getAutoGarbageCollect () const
 
size_t getChunkSize () const
 
T * getElement ()
 
T * getElement (const T &initializer)
 Get an element of type T, if we have ran out, then allocate a new chunks.
 
size_t memUsed () const
 
void setAutoGarbageCollect (int n)
 Set the number of calls to flush which will trigger a call to garbageCollect.
 
void setChunkSize (size_t size)
 Set the new size of the chunk.
 
void setEnableCallConstructor (bool flag)
 Set to true if the constructor of the elements should be called BEFORE they are returned in getElement();.
 
void setMaxAllocationSize (size_t numBytes)
 Set the largest number of bytes a call to new will be.
 
size_t size () const
 
- Public Member Functions inherited from agx::ByteAllocator
 ByteAllocator (const ByteAllocator &other)
 
 ByteAllocator (const char *name="ByteAllocator")
 
void * allocateBytes (size_t numBytes, size_t alignment=16)
 Allocate a memory section of specified alignment.
 
void deallocateBytes (void *buffer)
 
void deallocateBytes (void *buffer, size_t numBytes)
 Deallocate a section previously allocated using allocateBytes method.
 
const char * getName () const
 
ByteAllocator & operator= (const ByteAllocator &other)
 
void setContainer (class Container *)
 

Additional Inherited Members

- Static Public Member Functions inherited from agx::ByteAllocator
static void initMemory (void *data, size_t numBytes, agx::UInt32 pattern)
 
static void * standaloneAllocateBytes (size_t numBytes, size_t alignment=16)
 
static void standaloneDeallocateTypes (void *buffer)
 
- Static Public Attributes inherited from agx::ByteAllocator
static agx::UInt32 allocatedMemoryPattern
 
static agx::UInt32 deallocatedMemoryPattern
 
static bool initMemoryFlag
 

Detailed Description

template<typename T>
class agx::MemoryPoolOld< T >

Definition at line 151 of file MemoryPool.h.

Constructor & Destructor Documentation

◆ MemoryPoolOld()

template<typename T >
agx::MemoryPoolOld< T >::MemoryPoolOld ( size_t  initialSize = 0,
size_t  chunkSize = 64 
)

Definition at line 253 of file MemoryPool.h.

◆ ~MemoryPoolOld()

template<typename T >
agx::MemoryPoolOld< T >::~MemoryPoolOld

Definition at line 264 of file MemoryPool.h.

Member Function Documentation

◆ acquire()

template<typename T >
T * agx::MemoryPoolOld< T >::acquire ( )
inline
Returns
an element of type T from the pool. (same as getElement()

Definition at line 178 of file MemoryPool.h.

References agx::MemoryPoolOld< T >::getElement().

◆ capacity()

template<typename T >
size_t agx::MemoryPoolOld< T >::capacity

\ return the total number of elements allocated

Definition at line 308 of file MemoryPool.h.

References m_capacity.

◆ clear()

template<typename T >
void agx::MemoryPoolOld< T >::clear

Clear all memory allocated by this MemoryPoolOld.

Definition at line 371 of file MemoryPool.h.

References m_capacity, and agx::Container::SHRINK_BUFFER.

◆ flush()

template<typename T >
void agx::MemoryPoolOld< T >::flush

Return all elements to container.

Definition at line 428 of file MemoryPool.h.

◆ garbageCollect()

template<typename T >
void agx::MemoryPoolOld< T >::garbageCollect

Free memory not in use.

Based on the average allocation size (measured at each call to flush), only memory enough to store the average number of elements will be left.

Definition at line 445 of file MemoryPool.h.

References m_capacity.

◆ getAutoGarbageCollect()

template<typename T >
int agx::MemoryPoolOld< T >::getAutoGarbageCollect
Returns
number of calls to flush which will trigger a garbageCollect

Definition at line 320 of file MemoryPool.h.

◆ getChunkSize()

template<typename T >
size_t agx::MemoryPoolOld< T >::getChunkSize
Returns
the current chunkSize

Definition at line 276 of file MemoryPool.h.

◆ getElement() [1/2]

template<typename T >
T * agx::MemoryPoolOld< T >::getElement
inline
Returns
an element of type T from the pool.

Definition at line 326 of file MemoryPool.h.

Referenced by agx::MemoryPoolOld< T >::acquire().

◆ getElement() [2/2]

template<typename T >
T * agx::MemoryPoolOld< T >::getElement ( const T &  initializer)
inline

Get an element of type T, if we have ran out, then allocate a new chunks.

Returns
a pointer to an unused element of type T.

Definition at line 350 of file MemoryPool.h.

◆ memUsed()

template<typename T >
size_t agx::MemoryPoolOld< T >::memUsed
Returns
the total memory allocated in the chunks

Definition at line 282 of file MemoryPool.h.

◆ setAutoGarbageCollect()

template<typename T >
void agx::MemoryPoolOld< T >::setAutoGarbageCollect ( int  n)
inline

Set the number of calls to flush which will trigger a call to garbageCollect.

Parameters
n- Number of calls to flush to get garbageCollect, default: -1 (never)

Definition at line 314 of file MemoryPool.h.

◆ setChunkSize()

template<typename T >
void agx::MemoryPoolOld< T >::setChunkSize ( size_t  size)

Set the new size of the chunk.

Chunks created after this call will have this size.

Definition at line 270 of file MemoryPool.h.

◆ setEnableCallConstructor()

template<typename T >
void agx::MemoryPoolOld< T >::setEnableCallConstructor ( bool  flag)
inline

Set to true if the constructor of the elements should be called BEFORE they are returned in getElement();.

Definition at line 295 of file MemoryPool.h.

◆ setMaxAllocationSize()

template<typename T >
void agx::MemoryPoolOld< T >::setMaxAllocationSize ( size_t  numBytes)
inline

Set the largest number of bytes a call to new will be.

Definition at line 301 of file MemoryPool.h.

◆ size()

template<typename T >
size_t agx::MemoryPoolOld< T >::size
Returns
number of elements currently in use

Definition at line 289 of file MemoryPool.h.


The documentation for this class was generated from the following file: