![]() |
ATLAS Offline Software
|
Heap-based allocator. More...
#include <ArenaHeapAllocator.h>
Public Types | |
| typedef ArenaAllocatorBase::initParams< T, clear, no_ctor, no_dtor > | Base |
Public Member Functions | |
| initParams (size_t nblock=1000, const std::string &name="") | |
| Constructor. | |
| ArenaAllocatorBase::Params | params () const |
| Return an initialized parameters structure. | |
| operator ArenaAllocatorBase::Params () const | |
| Return an initialized parameters structure. | |
| operator Params () const | |
| Return an initialized parameters structure. | |
Private Attributes | |
| size_t | m_nblock |
| Saved value of the number of elements to allocate per block. | |
| std::string | m_name |
| Saved value of the allocator name. | |
Heap-based allocator.
See Arena.h for an overview of the arena-based memory allocators.
This is a block-based memory allocator, with heap-like behavior. This allows freeing individual elements, but we don't implement resetTo or an iterator.
There are some extra costs though.
We need an additional pointer (`link') for each free element.
By default, this is done by increasing the element size by a pointer, since we don't know whether there is data in the element itself that must be preserved across free/allocate. However, if you know that part of the element may be safely while it is free, then the allocator can be configured to use that as the link instead.
When reset() is called, we need to call clear() on all allocated elements (if it is defined). If canReclear is set, then we just call clear() on all elements in allocated blocks on reset(), regardless of whether or not the individual elements are allocated or not. Otherwise, we make two passes over the elements, first to build a list of those that are allocated and second to actually call clear().
An intermediate strategy, not currently implemented, could be used if the link does not overlap the element: set the link to a magic value when an element is allocated. */ class ArenaHeapAllocator : public ArenaBlockAllocatorBase { public: /**
Helper to initialize a parameters structure.
This creates a Params class appropriately initialized for class T. Assumptions made:
clear is true.canReclear is true and mustClear is false.If these are not appropriate, you can derive from this class and make the appropriate changes.
Definition at line 86 of file ArenaHeapAllocator.h.
| typedef ArenaAllocatorBase::initParams<T, clear, no_ctor, no_dtor> SG::initParams< T, clear, no_ctor, no_dtor >::Base |
Definition at line 90 of file ArenaHeapAllocator.h.
| SG::initParams< T, clear, no_ctor, no_dtor >::initParams | ( | size_t | nblock = 1000, |
| const std::string & | name = "" ) |
|
inline |
Return an initialized parameters structure.
Definition at line 107 of file ArenaHeapAllocator.h.
|
inlineinherited |
Return an initialized parameters structure.
Definition at line 335 of file ArenaAllocatorBase.h.
| ArenaAllocatorBase::Params SG::initParams< T, clear, no_ctor, no_dtor >::params | ( | ) | const |
Return an initialized parameters structure.
|
privateinherited |
Saved value of the allocator name.
Definition at line 343 of file ArenaAllocatorBase.h.
|
privateinherited |
Saved value of the number of elements to allocate per block.
Definition at line 340 of file ArenaAllocatorBase.h.