![]() |
aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
|
<agrum/base/core/smallObjectAllocator.h> More...
#include <smallObjectAllocator.h>
Public Member Functions | |
| void | displayStats () |
| Displays the number of allocation and deallocation made so far. | |
| Idx | nbAlloc () |
| Idx | nbDealloc () |
Allocator / Deallocator | |
| void * | allocate (const size_t &objectSize) |
| Allocates a block. | |
| void | deallocate (void *pDeallocatedObject, const size_t &objectSize) |
| Deallocates an object. | |
Static Public Member Functions | |
| static SmallObjectAllocator & | instance () |
Static Public Attributes | |
| static const size_t | GUM_DEFAULT_CHUNK_SIZE = 8096 |
| static const size_t | GUM_DEFAULT_MAX_OBJECT_SIZE = 512 |
Private Types | |
| using | _Pool_ = HashTable< Size, FixedAllocator* > |
| The pool containing FixedAllocator. | |
Private Attributes | |
| _Pool_ | _pool_ |
| std::size_t | _chunkSize_ |
| The memory that a chunk allocates. | |
| std::size_t | _maxObjectSize_ |
| The maximal size of an object befor new is called. | |
| Idx | nbAllocation |
| Idx | nbDeallocation |
Constructors / Destructors | |
| SmallObjectAllocator () | |
| Constructor. | |
| SmallObjectAllocator (const SmallObjectAllocator &) | |
| Copy Constructor (does nothing since we use a Singleton). | |
| SmallObjectAllocator & | operator= (const SmallObjectAllocator &) |
| Operator = (does nothing since we use a Singleton). | |
| virtual | ~SmallObjectAllocator () |
| Destructor. | |
<agrum/base/core/smallObjectAllocator.h>
Allocates objects of any size
SmallObjectAllocator does so by aggregating several FixedAllocator objects. When SmallObjectAllocator receives an allocation request, it either forwards it to the best matching FixedAllocator object or passes it to the default operator new
Definition at line 76 of file smallObjectAllocator.h.
|
private |
The pool containing FixedAllocator.
Definition at line 162 of file smallObjectAllocator.h.
|
private |
Constructor.
Greater object than maxObjectSize will be forwarded to op new.
Definition at line 72 of file smallObjectAllocator_inl.h.
References SmallObjectAllocator(), _chunkSize_, _maxObjectSize_, _pool_, GUM_DEFAULT_CHUNK_SIZE, GUM_DEFAULT_MAX_OBJECT_SIZE, nbAllocation, and nbDeallocation.
Referenced by SmallObjectAllocator(), SmallObjectAllocator(), ~SmallObjectAllocator(), instance(), and operator=().
|
inlineprivate |
Copy Constructor (does nothing since we use a Singleton).
Definition at line 110 of file smallObjectAllocator.h.
References SmallObjectAllocator().
|
virtual |
Destructor.
Definition at line 89 of file smallObjectAllocator_inl.h.
References SmallObjectAllocator(), and _pool_.
| INLINE void * gum::SmallObjectAllocator::allocate | ( | const size_t & | objectSize | ) |
Allocates a block.
Definition at line 108 of file smallObjectAllocator_inl.h.
References _chunkSize_, _maxObjectSize_, _pool_, and nbAllocation.
Referenced by gum::AbstractLeaf::operator new(), gum::ActionSet::operator new(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator new(), gum::Chi2TestPolicy< GUM_SCALAR >::operator new(), gum::ComposedLeaf::operator new(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator new(), gum::ContingencyTable< GUM_SCALAR_A, GUM_SCALAR_B >::operator new(), gum::FusionContext< isInitial >::operator new(), gum::GTestPolicy< GUM_SCALAR >::operator new(), gum::InternalNode::operator new(), gum::ITestPolicy< GUM_SCALAR >::operator new(), gum::LeafPair::operator new(), gum::LeastSquareTestPolicy< GUM_SCALAR >::operator new(), gum::Link< T >::operator new(), gum::LinkedList< T >::operator new(), gum::NodeDatabase< AttributeSelection, isScalar >::operator new(), gum::O4DGContext::operator new(), gum::Observation::operator new(), and gum::Parent::operator new().
| INLINE void gum::SmallObjectAllocator::deallocate | ( | void * | pDeallocatedObject, |
| const size_t & | objectSize ) |
Deallocates an object.
| pDeallocatedObject | is the object to be deallocated |
| objectSize | is the size of that object (useful for faster deallocation) |
Definition at line 141 of file smallObjectAllocator_inl.h.
References _maxObjectSize_, _pool_, and nbDeallocation.
Referenced by gum::Link< NodeId >::Link(), gum::AbstractLeaf::operator delete(), gum::ActionSet::operator delete(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator delete(), gum::Chi2TestPolicy< GUM_SCALAR >::operator delete(), gum::ComposedLeaf::operator delete(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator delete(), gum::ContingencyTable< GUM_SCALAR_A, GUM_SCALAR_B >::operator delete(), gum::FusionContext< isInitial >::operator delete(), gum::GTestPolicy< GUM_SCALAR >::operator delete(), gum::InternalNode::operator delete(), gum::ITestPolicy< GUM_SCALAR >::operator delete(), gum::LeafPair::operator delete(), gum::LeastSquareTestPolicy< GUM_SCALAR >::operator delete(), gum::LinkedList< T >::operator delete(), gum::NodeDatabase< AttributeSelection, isScalar >::operator delete(), gum::O4DGContext::operator delete(), gum::Observation::operator delete(), and gum::Parent::operator delete().
|
inline |
Displays the number of allocation and deallocation made so far.
Definition at line 149 of file smallObjectAllocator.h.
References nbAllocation, and nbDeallocation.
|
static |
Definition at line 95 of file smallObjectAllocator_inl.h.
References SmallObjectAllocator().
Referenced by gum::Link< NodeId >::Link(), gum::AbstractLeaf::operator delete(), gum::ActionSet::operator delete(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator delete(), gum::Chi2TestPolicy< GUM_SCALAR >::operator delete(), gum::ComposedLeaf::operator delete(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator delete(), gum::ContingencyTable< GUM_SCALAR_A, GUM_SCALAR_B >::operator delete(), gum::FusionContext< isInitial >::operator delete(), gum::GTestPolicy< GUM_SCALAR >::operator delete(), gum::InternalNode::operator delete(), gum::ITestPolicy< GUM_SCALAR >::operator delete(), gum::LeafPair::operator delete(), gum::LeastSquareTestPolicy< GUM_SCALAR >::operator delete(), gum::LinkedList< T >::operator delete(), gum::NodeDatabase< AttributeSelection, isScalar >::operator delete(), gum::O4DGContext::operator delete(), gum::Observation::operator delete(), gum::Parent::operator delete(), gum::AbstractLeaf::operator new(), gum::ActionSet::operator new(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator new(), gum::Chi2TestPolicy< GUM_SCALAR >::operator new(), gum::ComposedLeaf::operator new(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator new(), gum::ContingencyTable< GUM_SCALAR_A, GUM_SCALAR_B >::operator new(), gum::FusionContext< isInitial >::operator new(), gum::GTestPolicy< GUM_SCALAR >::operator new(), gum::InternalNode::operator new(), gum::ITestPolicy< GUM_SCALAR >::operator new(), gum::LeafPair::operator new(), gum::LeastSquareTestPolicy< GUM_SCALAR >::operator new(), gum::Link< T >::operator new(), gum::LinkedList< T >::operator new(), gum::NodeDatabase< AttributeSelection, isScalar >::operator new(), gum::O4DGContext::operator new(), gum::Observation::operator new(), gum::Parent::operator new(), and operator=().
|
inline |
|
inline |
|
inlineprivate |
Operator = (does nothing since we use a Singleton).
Definition at line 115 of file smallObjectAllocator.h.
References SmallObjectAllocator(), and instance().
|
private |
The memory that a chunk allocates.
Definition at line 169 of file smallObjectAllocator.h.
Referenced by SmallObjectAllocator(), and allocate().
|
private |
The maximal size of an object befor new is called.
Definition at line 174 of file smallObjectAllocator.h.
Referenced by SmallObjectAllocator(), allocate(), and deallocate().
|
private |
Definition at line 164 of file smallObjectAllocator.h.
Referenced by SmallObjectAllocator(), ~SmallObjectAllocator(), allocate(), and deallocate().
|
static |
| The | default size of chunck of memory. These chuncks are pre-allocated memory space which are then split in small memory space of the size of a small object |
Definition at line 83 of file smallObjectAllocator.h.
Referenced by SmallObjectAllocator().
|
static |
| The | default maximal size under which an object is considered small. If an object size is over this limit, the normal new allocator is called. |
Definition at line 90 of file smallObjectAllocator.h.
Referenced by SmallObjectAllocator().
|
private |
Definition at line 176 of file smallObjectAllocator.h.
Referenced by SmallObjectAllocator(), allocate(), displayStats(), and nbAlloc().
|
private |
Definition at line 177 of file smallObjectAllocator.h.
Referenced by SmallObjectAllocator(), deallocate(), displayStats(), and nbDealloc().