![]() |
aGrUM
0.16.0
|
<agrum/core/smallObjectAllocator.h> More...
#include <smallObjectAllocator.h>
Public Member Functions | |
void | displayStats () |
Displays the number of allocation and deallocation made so far. More... | |
Idx | nbAlloc () |
Idx | nbDealloc () |
Allocator / Deallocator | |
void * | allocate (const size_t &objectSize) |
Allocates a block. More... | |
void | deallocate (void *pDeallocatedObject, const size_t &objectSize) |
Deallocates an object. More... | |
Static Public Attributes | |
static const size_t | GUM_DEFAULT_CHUNK_SIZE = 8096 |
static const size_t | GUM_DEFAULT_MAX_OBJECT_SIZE = 512 |
Static Public Member Functions | |
static SmallObjectAllocator & | instance () |
Constructors / Destructors | |
SmallObjectAllocator () | |
Constructor. More... | |
SmallObjectAllocator (const SmallObjectAllocator &) | |
Copy Constructor (does nothing since we use a Singleton) More... | |
SmallObjectAllocator & | operator= (const SmallObjectAllocator &) |
Operator = (does nothing since we use a Singleton) More... | |
virtual | ~SmallObjectAllocator () |
Destructor. More... | |
<agrum/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 55 of file smallObjectAllocator.h.
|
private |
The pool containing FixedAllocator.
Definition at line 142 of file smallObjectAllocator.h.
|
private |
Constructor.
Greater object than maxObjectSize will be forwarded to op new.
Definition at line 50 of file smallObjectAllocator_inl.h.
References __pool, nbAllocation, nbDeallocation, and gum::HashTable< Key, Val, Alloc >::setKeyUniquenessPolicy().
|
inlineprivate |
Copy Constructor (does nothing since we use a Singleton)
Definition at line 88 of file smallObjectAllocator.h.
|
virtual |
Destructor.
Definition at line 68 of file smallObjectAllocator_inl.h.
References __pool, gum::HashTable< Key, Val, Alloc >::begin(), and gum::HashTable< Key, Val, Alloc >::end().
Referenced by operator=().
INLINE void * gum::SmallObjectAllocator::allocate | ( | const size_t & | objectSize | ) |
Allocates a block.
Definition at line 87 of file smallObjectAllocator_inl.h.
References __chunkSize, __maxObjectSize, __pool, gum::HashTable< Key, Val, Alloc >::exists(), nbAllocation, and gum::HashTable< Key, Val, Alloc >::set().
Referenced by gum::Chi2TestPolicy< GUM_SCALAR >::operator new(), gum::O4DGContext::operator new(), gum::LeastSquareTestPolicy< GUM_SCALAR >::operator new(), gum::ComposedLeaf::operator new(), gum::Parent::operator new(), gum::ITestPolicy< GUM_SCALAR >::operator new(), gum::LeafPair::operator new(), gum::Observation::operator new(), gum::GTestPolicy< GUM_SCALAR >::operator new(), gum::AbstractLeaf::operator new(), gum::ContingencyTable< Idx, GUM_SCALAR >::operator new(), gum::FusionContext< true >::operator new(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator new(), gum::NodeDatabase< AttributeSelection, isScalar >::operator new(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator new(), gum::ActionSet::operator new(), gum::InternalNode::operator new(), and operator=().
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 120 of file smallObjectAllocator_inl.h.
References __maxObjectSize, __pool, and nbDeallocation.
Referenced by gum::Chi2TestPolicy< GUM_SCALAR >::operator delete(), gum::LeastSquareTestPolicy< GUM_SCALAR >::operator delete(), gum::ComposedLeaf::operator delete(), gum::O4DGContext::operator delete(), gum::ITestPolicy< GUM_SCALAR >::operator delete(), gum::LeafPair::operator delete(), gum::Observation::operator delete(), gum::Parent::operator delete(), gum::AbstractLeaf::operator delete(), gum::GTestPolicy< GUM_SCALAR >::operator delete(), gum::ContingencyTable< Idx, GUM_SCALAR >::operator delete(), gum::FusionContext< true >::operator delete(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator delete(), gum::NodeDatabase< AttributeSelection, isScalar >::operator delete(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator delete(), gum::ActionSet::operator delete(), gum::InternalNode::operator delete(), and operator=().
|
inline |
Displays the number of allocation and deallocation made so far.
Definition at line 129 of file smallObjectAllocator.h.
References nbAllocation, and nbDeallocation.
|
static |
Definition at line 74 of file smallObjectAllocator_inl.h.
Referenced by gum::Chi2TestPolicy< GUM_SCALAR >::operator delete(), gum::LeastSquareTestPolicy< GUM_SCALAR >::operator delete(), gum::ComposedLeaf::operator delete(), gum::O4DGContext::operator delete(), gum::ITestPolicy< GUM_SCALAR >::operator delete(), gum::LeafPair::operator delete(), gum::Observation::operator delete(), gum::Parent::operator delete(), gum::AbstractLeaf::operator delete(), gum::GTestPolicy< GUM_SCALAR >::operator delete(), gum::ContingencyTable< Idx, GUM_SCALAR >::operator delete(), gum::FusionContext< true >::operator delete(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator delete(), gum::NodeDatabase< AttributeSelection, isScalar >::operator delete(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator delete(), gum::ActionSet::operator delete(), gum::InternalNode::operator delete(), gum::Chi2TestPolicy< GUM_SCALAR >::operator new(), gum::O4DGContext::operator new(), gum::LeastSquareTestPolicy< GUM_SCALAR >::operator new(), gum::ComposedLeaf::operator new(), gum::ITestPolicy< GUM_SCALAR >::operator new(), gum::Parent::operator new(), gum::LeafPair::operator new(), gum::Observation::operator new(), gum::GTestPolicy< GUM_SCALAR >::operator new(), gum::AbstractLeaf::operator new(), gum::ContingencyTable< Idx, GUM_SCALAR >::operator new(), gum::FusionContext< true >::operator new(), gum::ConcreteLeaf< AttributeSelection, isScalar >::operator new(), gum::NodeDatabase< AttributeSelection, isScalar >::operator new(), gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator new(), gum::ActionSet::operator new(), gum::InternalNode::operator new(), and operator=().
|
inline |
|
inline |
|
inlineprivate |
Operator = (does nothing since we use a Singleton)
Definition at line 93 of file smallObjectAllocator.h.
References allocate(), deallocate(), instance(), and ~SmallObjectAllocator().
|
private |
The memory that a chunk allocates.
Definition at line 148 of file smallObjectAllocator.h.
Referenced by allocate().
|
private |
The maximal size of an object befor new is called.
Definition at line 153 of file smallObjectAllocator.h.
Referenced by allocate(), and deallocate().
|
private |
Definition at line 143 of file smallObjectAllocator.h.
Referenced by allocate(), deallocate(), SmallObjectAllocator(), and ~SmallObjectAllocator().
|
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 62 of file smallObjectAllocator.h.
|
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 69 of file smallObjectAllocator.h.
|
private |
Definition at line 155 of file smallObjectAllocator.h.
Referenced by allocate(), displayStats(), nbAlloc(), and SmallObjectAllocator().
|
private |
Definition at line 156 of file smallObjectAllocator.h.
Referenced by deallocate(), displayStats(), nbDealloc(), and SmallObjectAllocator().