![]() |
aGrUM 3.1.1
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. | |
| std::mutex | _mutex_ |
| Idx | nbAllocation |
| Idx | nbDeallocation |
Constructors / Destructors | |
| SmallObjectAllocator () | |
| Constructor. | |
| SmallObjectAllocator (const SmallObjectAllocator &)=delete | |
| 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 159 of file smallObjectAllocator.h.
|
private |
Constructor.
Greater object than maxObjectSize will be forwarded to op new.
Definition at line 73 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=().
|
privatedelete |
Copy Constructor (does nothing since we use a Singleton).
References SmallObjectAllocator().
|
virtual |
Destructor.
Definition at line 90 of file smallObjectAllocator_inl.h.
References SmallObjectAllocator(), and _pool_.
| void * gum::SmallObjectAllocator::allocate | ( | const size_t & | objectSize | ) |
Allocates a block.
Definition at line 72 of file smallObjectAllocator.cpp.
References _chunkSize_, _maxObjectSize_, _mutex_, _pool_, and nbAllocation.
Referenced by gum::ContingencyTable< Idx, GUM_ELEMENT >::attrAEndSafe(), gum::FusionContext< false >::leaf(), gum::AbstractLeaf::operator new(), gum::ActionSet::operator new(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator new(), gum::Chi2TestPolicy< GUM_ELEMENT >::operator new(), gum::ComposedLeaf::operator new(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator new(), gum::GTestPolicy< GUM_ELEMENT >::operator new(), gum::InternalNode::operator new(), gum::ITestPolicy< GUM_ELEMENT >::operator new(), gum::LeafPair::operator new(), gum::LeastSquareTestPolicy< GUM_ELEMENT >::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 116 of file smallObjectAllocator_inl.h.
References _maxObjectSize_, _mutex_, _pool_, and nbDeallocation.
Referenced by gum::Link< NodeId >::Link(), gum::FusionContext< false >::leafAssociatedPair(), gum::AbstractLeaf::operator delete(), gum::ActionSet::operator delete(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator delete(), gum::Chi2TestPolicy< GUM_ELEMENT >::operator delete(), gum::ComposedLeaf::operator delete(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator delete(), gum::GTestPolicy< GUM_ELEMENT >::operator delete(), gum::InternalNode::operator delete(), gum::ITestPolicy< GUM_ELEMENT >::operator delete(), gum::LeafPair::operator delete(), gum::LeastSquareTestPolicy< GUM_ELEMENT >::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 void gum::SmallObjectAllocator::displayStats | ( | ) |
Displays the number of allocation and deallocation made so far.
Definition at line 137 of file smallObjectAllocator_inl.h.
References nbAllocation, and nbDeallocation.
|
static |
Definition at line 96 of file smallObjectAllocator_inl.h.
References SmallObjectAllocator().
Referenced by gum::Link< NodeId >::Link(), gum::ContingencyTable< Idx, GUM_ELEMENT >::attrAEndSafe(), gum::FusionContext< false >::leaf(), gum::FusionContext< false >::leafAssociatedPair(), gum::AbstractLeaf::operator delete(), gum::ActionSet::operator delete(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator delete(), gum::Chi2TestPolicy< GUM_ELEMENT >::operator delete(), gum::ComposedLeaf::operator delete(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator delete(), gum::GTestPolicy< GUM_ELEMENT >::operator delete(), gum::InternalNode::operator delete(), gum::ITestPolicy< GUM_ELEMENT >::operator delete(), gum::LeafPair::operator delete(), gum::LeastSquareTestPolicy< GUM_ELEMENT >::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_ELEMENT >::operator new(), gum::ComposedLeaf::operator new(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator new(), gum::GTestPolicy< GUM_ELEMENT >::operator new(), gum::InternalNode::operator new(), gum::ITestPolicy< GUM_ELEMENT >::operator new(), gum::LeafPair::operator new(), gum::LeastSquareTestPolicy< GUM_ELEMENT >::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 Idx gum::SmallObjectAllocator::nbAlloc | ( | ) |
| INLINE Idx gum::SmallObjectAllocator::nbDealloc | ( | ) |
|
private |
Operator = (does nothing since we use a Singleton).
Definition at line 133 of file smallObjectAllocator_inl.h.
References SmallObjectAllocator(), and instance().
|
private |
The memory that a chunk allocates.
Definition at line 166 of file smallObjectAllocator.h.
Referenced by SmallObjectAllocator(), and allocate().
|
private |
The maximal size of an object befor new is called.
Definition at line 171 of file smallObjectAllocator.h.
Referenced by SmallObjectAllocator(), allocate(), and deallocate().
|
private |
Definition at line 174 of file smallObjectAllocator.h.
Referenced by allocate(), and deallocate().
|
private |
Definition at line 161 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().