Open CASCADE Technology
6.9.1
|
Class NCollection_AccAllocator - accumulating memory allocator. This class allocates memory on request returning the pointer to the allocated space. The allocation units are grouped in blocks requested from the system as required. This memory is returned to the system when all allocations in a block are freed. More...
#include <NCollection_AccAllocator.hxx>
Data Structures | |
class | AlignedPtr |
A pointer aligned to a 4 byte boundary. More... | |
class | AlignedSize |
Size value aligned to a 4 byte boundary. More... | |
struct | Block |
Descriptor of a block. More... | |
class | Hasher |
Key hasher. More... | |
struct | Key |
A key for the map of blocks. More... | |
Public Member Functions | |
NCollection_AccAllocator (const size_t theBlockSize=DefaultBlockSize) | |
Constructor. More... | |
~NCollection_AccAllocator () | |
Destructor. More... | |
virtual void * | Allocate (const size_t theSize) |
Allocate memory with given size. More... | |
virtual void | Free (void *theAddress) |
Free a previously allocated memory; memory is returned to the OS when all allocations in some block are freed. More... | |
Public Member Functions inherited from MMgt_TShared | |
virtual void | Delete () const |
Memory deallocator for transient classes. More... | |
Public Member Functions inherited from Standard_Transient | |
Standard_Transient () | |
Empty constructor. More... | |
Standard_Transient (const Standard_Transient &) | |
Copy constructor – does nothing. More... | |
Standard_Transient & | operator= (const Standard_Transient &) |
Assignment operator, needed to avoid copying reference counter. More... | |
virtual | ~Standard_Transient () |
Destructor must be virtual. More... | |
virtual const Handle_Standard_Type & | DynamicType () const |
Returns a type information object about this object. More... | |
Standard_Boolean | IsInstance (const Handle_Standard_Type &theType) const |
Returns a true value if this is an instance of Type. More... | |
Standard_Boolean | IsInstance (const Standard_CString theTypeName) const |
Returns a true value if this is an instance of TypeName. More... | |
Standard_Boolean | IsKind (const Handle_Standard_Type &theType) const |
Returns true if this is an instance of Type or an instance of any class that inherits from Type. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More... | |
Standard_Boolean | IsKind (const Standard_CString theTypeName) const |
Returns true if this is an instance of TypeName or an instance of any class that inherits from TypeName. Note that multiple inheritance is not supported by OCCT RTTI mechanism. More... | |
virtual Handle_Standard_Transient | This () const |
Returns a Handle which references this object. Must never be called to objects created in stack. More... | |
Standard_Integer | GetRefCount () const |
Get the reference counter of this object. More... | |
Static Public Attributes | |
static const Standard_Size | Align = 4 |
Alignment of all allocated objects: 4 bytes. More... | |
static const Standard_Size | DefaultBlockSize = 24600 |
Default block size. More... | |
static const Standard_Integer | MaxLookupBlocks = 16 |
Number of last blocks to check for free space. More... | |
Protected Member Functions | |
Key | getKey (const Standard_Address theAddress) const |
Calculate a key for the data map basing on the given address. More... | |
Block * | findBlock (const Standard_Address theAddress, Key &theKey) |
Find a block that the given allocation unit belongs to. More... | |
Block * | allocateNewBlock (const Standard_Size theSize) |
Allocate a new block and return a pointer to it. More... | |
Protected Member Functions inherited from NCollection_BaseAllocator | |
NCollection_BaseAllocator (void) | |
Constructor - prohibited. More... | |
Protected Attributes | |
AlignedSize | myBlockSize |
Block * | mypLastBlock |
NCollection_DataMap< Key, Block, Hasher > | myBlocks |
Additional Inherited Members | |
Static Public Member Functions inherited from NCollection_BaseAllocator | |
static const Handle< NCollection_BaseAllocator > & | CommonBaseAllocator (void) |
CommonBaseAllocator This method is designed to have the only one BaseAllocator (to avoid useless copying of collections). However one can use operator new to create more BaseAllocators, but it is injurious. More... | |
static void | StandardCallBack (const Standard_Boolean theIsAlloc, const Standard_Address theStorage, const Standard_Size theRoundSize, const Standard_Size theSize) |
Callback function to register alloc/free calls. More... | |
static void | PrintMemUsageStatistics () |
Prints memory usage statistics cumulated by StandardCallBack. More... | |
Class NCollection_AccAllocator - accumulating memory allocator. This class allocates memory on request returning the pointer to the allocated space. The allocation units are grouped in blocks requested from the system as required. This memory is returned to the system when all allocations in a block are freed.
By comparison with the standard new() and malloc() calls, this method is faster and consumes very small additional memory to maintain the heap.
By comparison with NCollection_IncAllocator, this class requires some more additional memory and a little more time for allocation and deallocation. Memory overhead for NCollection_IncAllocator is 12 bytes per block; average memory overhead for NCollection_AccAllocator is 28 bytes per block.
All pointers returned by Allocate() are aligned to 4 byte boundaries. To define the size of memory blocks requested from the OS, use the parameter of the constructor (measured in bytes).
NCollection_AccAllocator::NCollection_AccAllocator | ( | const size_t | theBlockSize = DefaultBlockSize | ) |
Constructor.
NCollection_AccAllocator::~NCollection_AccAllocator | ( | ) |
Destructor.
|
virtual |
Allocate memory with given size.
Reimplemented from NCollection_BaseAllocator.
|
protected |
Allocate a new block and return a pointer to it.
|
protected |
Find a block that the given allocation unit belongs to.
|
virtual |
Free a previously allocated memory; memory is returned to the OS when all allocations in some block are freed.
Reimplemented from NCollection_BaseAllocator.
|
inlineprotected |
Calculate a key for the data map basing on the given address.
|
static |
Alignment of all allocated objects: 4 bytes.
|
static |
Default block size.
|
static |
Number of last blocks to check for free space.
|
protected |
|
protected |
|
protected |