Lumiera  0.pre.03
»edit your freedom«
TrackingAllocator Class Reference

#include "lib/test/tracking-allocator.hpp"

Description

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 *
 

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. More...
 
void deallocate (Location, size_t=0) noexcept
 Discard and forget an allocation created through this allocator. More...
 
HashVal getID (Location) const
 retrieve the internal registration ID for this allocation. More...
 
size_t getSize (Location) const
 retrieve the registered size of this allocation, if known. More...
 
bool manages (Location) const
 probe if this allocator pool did allocate the given memory location
 
Literal poolID () const
 

Static Public Member Functions

static HashVal checksum (Literal pool=GLOBAL)
 get Checksum for specific mem-pool
 
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
 
static size_t use_count (Literal pool=GLOBAL)
 determine number of active front-end handles
 

Static Public Attributes

static EventLog log {"test::TrackingAllocator"}
 

Friends

bool operator!= (TrackingAllocator const &a1, TrackingAllocator const &a2)
 
bool operator== (TrackingAllocator const &a1, TrackingAllocator const &a2)
 

Private Attributes

PoolHandle mem_
 

Member Function Documentation

◆ allocate()

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.

Returns
a void* to the start of the bare memory location

Definition at line 188 of file tracking-allocator.cpp.

Referenced by TrackAlloc< TY >::allocate(), and TrackingFactory::create().

+ Here is the caller graph for this function:

◆ deallocate()

void deallocate ( Location  loc,
size_t  bytes = 0 
)
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(), and TrackingFactory::dispose().

+ Here is the caller graph for this function:

◆ getSize()

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 steam::mobject::session::query::anonymous_namespace{fake-configrules.cpp}::entry().

+ Here is the call graph for this function:

◆ getID()

HashVal getID ( Location  memLoc) const

retrieve the internal registration ID for this allocation.

Definition at line 329 of file tracking-allocator.cpp.

References steam::mobject::session::query::anonymous_namespace{fake-configrules.cpp}::entry().

+ Here is the call graph for this function:
+ Inheritance diagram for TrackingAllocator:
+ Collaboration diagram for TrackingAllocator:

The documentation for this class was generated from the following files: