AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 ()
 
void * allocateBytes (size_t numBytes, size_t alignment=16)
 Allocate a memory section of specified alignment. More...
 
size_t capacity () const
 \ return the total number of elements allocated More...
 
void clear ()
 Clear all memory allocated by this MemoryPoolOld. More...
 
void deallocateBytes (void *buffer, size_t numBytes)
 Deallocate a section previously allocated using allocateBytes method. More...
 
void deallocateBytes (void *buffer)
 
void flush ()
 Return all elements to container. More...
 
void garbageCollect ()
 Free memory not in use. More...
 
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. More...
 
const char * getName () const
 
size_t memUsed () const
 
void setAutoGarbageCollect (int n)
 Set the number of calls to flush which will trigger a call to garbageCollect. More...
 
void setChunkSize (size_t size)
 Set the new size of the chunk. More...
 
void setContainer (class Container *)
 
void setEnableCallConstructor (bool flag)
 Set to true if the constructor of the elements should be called BEFORE they are returned in getElement();. More...
 
void setMaxAllocationSize (size_t numBytes)
 Set the largest number of bytes a call to new will be. More...
 
size_t size () const
 

Static Public Member Functions

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

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

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

Definition at line 253 of file MemoryPool.h.

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

Definition at line 264 of file MemoryPool.h.

References agxTerrain::Profiler::clear().

Member Function Documentation

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().

void* agx::ByteAllocator::allocateBytes ( size_t  numBytes,
size_t  alignment = 16 
)
inherited

Allocate a memory section of specified alignment.

Referenced by agx::Allocator< T >::allocate(), and agx::AlignedAllocator< T >::allocate().

template<typename T >
size_t agx::MemoryPoolOld< T >::capacity ( ) const

\ return the total number of elements allocated

Definition at line 308 of file MemoryPool.h.

References m_capacity.

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.

void agx::ByteAllocator::deallocateBytes ( void *  buffer)
inherited

Definition at line 173 of file Allocator.h.

References agx::ByteAllocator::deallocateBytes().

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

Return all elements to container.

Definition at line 428 of file MemoryPool.h.

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.

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

Definition at line 320 of file MemoryPool.h.

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

Definition at line 276 of file MemoryPool.h.

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().

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.

const char * agx::ByteAllocator::getName ( ) const
inherited
Returns
The name

Definition at line 164 of file Allocator.h.

static void agx::ByteAllocator::initMemory ( void *  data,
size_t  numBytes,
agx::UInt32  pattern 
)
staticinherited
template<typename T >
size_t agx::MemoryPoolOld< T >::memUsed ( ) const
Returns
the total memory allocated in the chunks

Definition at line 282 of file MemoryPool.h.

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.

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.

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.

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.

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

Definition at line 289 of file MemoryPool.h.

static void* agx::ByteAllocator::standaloneAllocateBytes ( size_t  numBytes,
size_t  alignment = 16 
)
staticinherited
static void agx::ByteAllocator::standaloneDeallocateTypes ( void *  buffer)
staticinherited

Member Data Documentation

agx::UInt32 agx::ByteAllocator::allocatedMemoryPattern
staticinherited

Definition at line 79 of file Allocator.h.

agx::UInt32 agx::ByteAllocator::deallocatedMemoryPattern
staticinherited

Definition at line 80 of file Allocator.h.

bool agx::ByteAllocator::initMemoryFlag
staticinherited

Definition at line 78 of file Allocator.h.


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