Nektar++
|
General purpose memory allocation routines with the ability to allocate from thread specific memory pools. More...
#include <NekMemoryManager.hpp>
Classes | |
class | DeallocateSharedPtr |
class | DefaultCustomDeallocator |
struct | rebind |
Static Public Member Functions | |
static void | Deallocate (DataType *&data) |
Deallocate a pointer allocated by MemoryManager::Allocate. | |
static DataType * | Allocate () |
Allocates a single object from the memory pool. | |
static boost::shared_ptr < DataType > | AllocateSharedPtr () |
Allocate a shared pointer from the memory pool. | |
static DataType * | RawAllocate (unsigned int NumberOfElements) |
Allocates a chunk of raw, uninitialized memory, capable of holding NumberOfElements objects. | |
static void | RawDeallocate (DataType *array, unsigned int NumberOfElements) |
Deallocates memory allocated from RawAllocate. |
Allocator Interface | |
The allocator interface allows a MemoryManager object to be used in any object that allows an allocator parameter, such as STL containers. ////////////////////////////////////////////////////////////// | |
typedef DataType | value_type |
typedef size_t | size_type |
typedef ptrdiff_t | difference_type |
typedef DataType * | pointer |
typedef const DataType * | const_pointer |
typedef DataType & | reference |
typedef const DataType & | const_reference |
MemoryManager () | |
template<typename T > | |
MemoryManager (const MemoryManager< T > &rhs) | |
~MemoryManager () | |
pointer | address (reference r) const |
const_pointer | address (const_reference r) const |
pointer | allocate (size_type n, std::allocator< void >::const_pointer hint=0) |
void | deallocate (pointer p, size_type n) |
void | construct (pointer p, const_reference val) |
void | destroy (pointer p) |
size_type | max_size () |
General purpose memory allocation routines with the ability to allocate from thread specific memory pools.
If compiled with NEKTAR_MEMORY_POOL_ENABLED, the MemoryManager allocates from thread specific memory pools for small objects. Large objects are managed with the system supplied new/delete. These memory pools provide faster allocation and deallocation of small objects (particularly useful for shared pointers which allocate many 4 byte objects).
Definition at line 102 of file NekMemoryManager.hpp.
typedef const DataType* Nektar::MemoryManager< DataType >::const_pointer |
Definition at line 326 of file NekMemoryManager.hpp.
typedef const DataType& Nektar::MemoryManager< DataType >::const_reference |
Definition at line 328 of file NekMemoryManager.hpp.
typedef ptrdiff_t Nektar::MemoryManager< DataType >::difference_type |
Definition at line 324 of file NekMemoryManager.hpp.
typedef DataType* Nektar::MemoryManager< DataType >::pointer |
Definition at line 325 of file NekMemoryManager.hpp.
typedef DataType& Nektar::MemoryManager< DataType >::reference |
Definition at line 327 of file NekMemoryManager.hpp.
typedef size_t Nektar::MemoryManager< DataType >::size_type |
Definition at line 323 of file NekMemoryManager.hpp.
typedef DataType Nektar::MemoryManager< DataType >::value_type |
Definition at line 322 of file NekMemoryManager.hpp.
|
inline |
Definition at line 330 of file NekMemoryManager.hpp.
|
inline |
Definition at line 332 of file NekMemoryManager.hpp.
|
inline |
Definition at line 333 of file NekMemoryManager.hpp.
|
inline |
Definition at line 335 of file NekMemoryManager.hpp.
|
inline |
Definition at line 336 of file NekMemoryManager.hpp.
|
inlinestatic |
Allocates a single object from the memory pool.
unknown | Any exception thrown by DataType's default constructor will propogate through this method. |
The allocated object must be returned to the memory pool via Deallocate.
Definition at line 215 of file NekMemoryManager.hpp.
|
inline |
Definition at line 338 of file NekMemoryManager.hpp.
References Nektar::MemoryManager< DataType >::RawAllocate().
|
inlinestatic |
Allocate a shared pointer from the memory pool.
The shared pointer does not need to be returned to the memory pool. When the reference count to this object reaches 0, the shared pointer will automatically return the memory.
Definition at line 235 of file NekMemoryManager.hpp.
Referenced by Diffusion::Diffusion(), main(), and SetFields().
Nektar::MemoryManager< DataType >::BOOST_PP_REPEAT_FROM_TO | ( | 1 | , |
NEKTAR_MAX_MEMORY_MANAGER_CONSTRUCTOR_ARGS | , | ||
ALLOCATE_METHOD_GENERATOR | , | ||
Allocate | |||
) |
Nektar::MemoryManager< DataType >::BOOST_PP_REPEAT_FROM_TO | ( | 0 | , |
NEKTAR_MAX_MEMORY_MANAGER_CONSTRUCTOR_ARGS | , | ||
ALLOCATE_SHARED_PTR_METHOD_WITH_DEALLOCATOR_GENERATOR | , | ||
AllocateSharedPtrD | |||
) |
Nektar::MemoryManager< DataType >::BOOST_PP_REPEAT_FROM_TO | ( | 1 | , |
NEKTAR_MAX_MEMORY_MANAGER_CONSTRUCTOR_ARGS | , | ||
ALLOCATE_SHARED_PTR_METHOD_GENERATOR | , | ||
AllocateSharedPtr | |||
) |
|
inline |
Definition at line 348 of file NekMemoryManager.hpp.
|
inlinestatic |
Deallocate a pointer allocated by MemoryManager::Allocate.
Use this method to deallocate a pointer you have allocated from the MemoryManager using the Allocate method.
Example:
Definition at line 147 of file NekMemoryManager.hpp.
References Nektar::MemPool::Deallocate(), and Nektar::GetMemoryPool().
Referenced by Nektar::MemoryManager< DataType >::DeallocateSharedPtr< ObjectType, CustomDeallocator >::operator()().
|
inline |
Definition at line 343 of file NekMemoryManager.hpp.
References Nektar::MemoryManager< DataType >::RawDeallocate().
|
inline |
Definition at line 353 of file NekMemoryManager.hpp.
|
inline |
Definition at line 358 of file NekMemoryManager.hpp.
|
inlinestatic |
Allocates a chunk of raw, uninitialized memory, capable of holding NumberOfElements objects.
NumberOfElements | The number of elements the array should be capable of holding. |
This method is not meant to be called by client code. Use Array instead. Any memory allocated from this method must be returned to the memory pool via RawDeallocate. Failure to do so will result in memory leaks and undefined behavior.
Definition at line 290 of file NekMemoryManager.hpp.
References Nektar::MemPool::Allocate(), and Nektar::GetMemoryPool().
Referenced by Nektar::MemoryManager< DataType >::allocate(), and Nektar::CreateStorage().
|
inlinestatic |
Deallocates memory allocated from RawAllocate.
array | A pointer to the memory returned from RawAllocate. |
NumberOfElements | The number of object held in the array. |
This method is not meant to be called by client code. Use Array instead. Only memory allocated via RawAllocate should be returned to the pool here.
Definition at line 306 of file NekMemoryManager.hpp.
References Nektar::MemPool::Deallocate(), and Nektar::GetMemoryPool().
Referenced by Nektar::MemoryManager< DataType >::deallocate(), and Nektar::DeleteStorage().