![]() |
Lumiera 0.pre.04
»edit your freedom«
|
#include "lib/test/tracking-allocator.hpp"
Generic low-level allocator attached to tracking MemoryPool.
Effectively this is a shared handle front-end to the MemoryPool, and new distinct pools are generated (and discarded) on demand, keyed by a pool-ID. A global (singleton) pool is used when no pool-ID is explicitly given.
Definition at line 83 of file tracking-allocator.hpp.
Public Types | |
| using | Location = void * |
Static Public Attributes | |
| static EventLog | log {"test::TrackingAllocator"} |
Static Public Member Functions | |
| static HashVal | checksum (Literal pool=GLOBAL) |
| get Checksum for specific mem-pool | |
| static size_t | use_count (Literal pool=GLOBAL) |
| determine number of active front-end handles | |
| static size_t | numAlloc (Literal pool=GLOBAL) |
| get active allocation count for mem-pool | |
| static size_t | numBytes (Literal pool=GLOBAL) |
| calculate currently allotted Bytes for mem-pool | |
Public Member Functions | |
| TrackingAllocator () | |
| can be default created to attach to a common pool | |
| TrackingAllocator (Literal id) | |
| create a separate, marked memory pool | |
| Location | allocate (size_t n) |
| Allot a memory block of given size bytes. | |
| void | deallocate (Location, size_t=0) noexcept |
| Discard and forget an allocation created through this allocator. | |
| bool | manages (Location) const |
| probe if this allocator pool did allocate the given memory location | |
| size_t | getSize (Location) const |
| retrieve the registered size of this allocation, if known. | |
| HashVal | getID (Location) const |
| retrieve the internal registration ID for this allocation. | |
| Literal | poolID () const |
Friends | |
| bool | operator== (TrackingAllocator const &a1, TrackingAllocator const &a2) |
| bool | operator!= (TrackingAllocator const &a1, TrackingAllocator const &a2) |
Private Attributes | |
| PoolHandle | mem_ |
can be default created to attach to a common pool
Definition at line 172 of file tracking-allocator.cpp.
| TrackingAllocator | ( | Literal | id | ) |
create a separate, marked memory pool
Definition at line 176 of file tracking-allocator.cpp.
| using Location = void* |
Definition at line 96 of file tracking-allocator.hpp.
| TrackingAllocator::Location allocate | ( | size_t | bytes | ) |
Allot a memory block of given size bytes.
This allocation is recorded in the associated MemoryPool and proper deallocation can thus be verified.
void* to the start of the bare memory location Definition at line 188 of file tracking-allocator.cpp.
References TrackingAllocator::mem_.
Referenced by TrackAlloc< TY >::allocate(), TrackingFactory::create(), and TestTracking_test::demonstrate_checkAllocator().
Here is the caller graph for this function:
|
noexcept |
Discard and forget an allocation created through this allocator.
The bytes argument serves as sanity check (since the actual allocation size is recorded anyway); a mismatch is logged as error, yet silently ignored.
Definition at line 201 of file tracking-allocator.cpp.
Referenced by TrackAlloc< TY >::deallocate(), TestTracking_test::demonstrate_checkAllocator(), and TrackingFactory::dispose().
Here is the caller graph for this function:| bool manages | ( | Location | memLoc | ) | const |
probe if this allocator pool did allocate the given memory location
Definition at line 311 of file tracking-allocator.cpp.
References TrackingAllocator::mem_.
Referenced by TestTracking_test::demonstrate_checkAllocator().
Here is the caller graph for this function:| size_t getSize | ( | Location | memLoc | ) | const |
retrieve the registered size of this allocation, if known.
Definition at line 319 of file tracking-allocator.cpp.
References TrackingAllocator::mem_.
Referenced by TestTracking_test::demonstrate_checkAllocator().
Here is the caller graph for this function:retrieve the internal registration ID for this allocation.
Definition at line 329 of file tracking-allocator.cpp.
References TrackingAllocator::mem_.
Referenced by TestTracking_test::demonstrate_checkAllocator().
Here is the caller graph for this function:| Literal poolID | ( | ) | const |
Definition at line 338 of file tracking-allocator.cpp.
References TrackingAllocator::mem_.
Referenced by TrackingAllocator::checksum(), TrackingFactory::create(), TrackingFactory::dispose(), TrackingAllocator::numAlloc(), TrackingAllocator::numBytes(), and TrackingAllocator::use_count().
Here is the caller graph for this function:get Checksum for specific mem-pool
Definition at line 278 of file tracking-allocator.cpp.
References TrackingAllocator::poolID().
Referenced by SeveralBuilder_test::check_CustomAllocator(), and TestTracking_test::demonstrate_checkAllocator().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
determine number of active front-end handles
Definition at line 286 of file tracking-allocator.cpp.
References TrackingAllocator::poolID().
Referenced by SeveralBuilder_test::check_CustomAllocator(), and TestTracking_test::demonstrate_checkAllocator().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
get active allocation count for mem-pool
Definition at line 294 of file tracking-allocator.cpp.
References TrackingAllocator::poolID().
Referenced by SeveralBuilder_test::check_CustomAllocator(), and TestTracking_test::demonstrate_checkAllocator().
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
calculate currently allotted Bytes for mem-pool
Definition at line 302 of file tracking-allocator.cpp.
References TrackingAllocator::poolID().
Referenced by SeveralBuilder_test::check_CustomAllocator(), and TestTracking_test::demonstrate_checkAllocator().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Definition at line 85 of file tracking-allocator.hpp.
Referenced by TrackingAllocator::allocate(), TrackingAllocator::getID(), TrackingAllocator::getSize(), TrackingAllocator::manages(), and TrackingAllocator::poolID().
|
static |
Definition at line 126 of file tracking-allocator.hpp.
Referenced by TrackingFactory::create(), TestTracking_test::demonstrate_checkAllocator(), TrackingFactory::dispose(), and lib::test::anonymous_namespace{tracking-allocator.cpp}::log().
|
friend |
Definition at line 103 of file tracking-allocator.hpp.
|
friend |
Definition at line 108 of file tracking-allocator.hpp.
Inheritance diagram for TrackingAllocator:
Collaboration diagram for TrackingAllocator: