![]() |
ULIS
dev4.0.7
Utility Library for Imaging Systems
|
The FFixedAllocMemoryPool class is a class that provides a configurable pool of fixed alloc arenas buffer to manages allocations of fixed size data efficiently and optimize memory consumption by evaluating sparsity, occupation and fragmentation of the various arena pages and concatenate them if neccessary. It is meant to be used for tiles or any objects of fixed size, and can be driven asynchronously by a larger system if necessary. More...
Static Public Member Functions | |
static void | Free (tClient iClient) |
FFixedAllocMemoryPool allows to obtain fixed allocations inside that are resident of one arena page underlying block. It returns "clients" of the allocation, that is, a pointer to an allocation. The API is mostly similar to FFixedAllocArena, but the pool aggregates them in a list and manages fragmentation and higher level systems and algorithms to drive them efficiently.
FFixedAllocMemoryPool::~FFixedAllocMemoryPool | ( | ) |
Destructor, destroy the arenas pages. Cleanup the underlying arenas block. Make sure all allocations are free before destroying a pool, or it will trigger an assert in debug builds. You can use UnsafeFreeAll() before destruction to ensure it doesn't crash, but only if you know what you're doing. It is possible to do so before program termination, but if clients don't expect this, they will all be deleted without notification and induce a corrupted state within the program.
|
explicit |
Constructor from arena size and alloc size. Make sure to chose an arena size that is greater than the alloc size and that can fit an expected number of fixed cells allocations. It is best to chose an alloc size that is a divisor of arena size, the behaviour is undefined otherwise.
|
explicit |
Constructor from alloc size and number of expected cells or allocs. An arena size will be computed so that it can fit an expected number of fixed cells allocations.
|
delete |
Explicitely deleted copy constructor
uint64 FFixedAllocMemoryPool::AllocArenasToReachTargetMemory | ( | ) |
Alloc N empty arenas until memory target is reached. Return the number of allocated arenas.
bool FFixedAllocMemoryPool::AllocOneArenaIfNecessary | ( | ) |
Alloc empty arena page if target memory isn't reached.
byte_t FFixedAllocMemoryPool::AllocSize | ( | ) | const |
Obtain the alloc size in bytes
byte_t FFixedAllocMemoryPool::ArenaSize | ( | ) | const |
Obtain the arena size in bytes
void FFixedAllocMemoryPool::DebugPrint | ( | ) | const |
Get a textual representation of the arena for debug purposes.
void FFixedAllocMemoryPool::DefragForce | ( | ) |
Force trigger a defrag.
void FFixedAllocMemoryPool::DefragIfNecessary | ( | ) |
Trigger a defrag only if the threshold is reached.
ufloat FFixedAllocMemoryPool::DefragThreshold | ( | ) | const |
Get the defrag theshold.
ufloat FFixedAllocMemoryPool::Fragmentation | ( | ) | const |
Arbitrary heuristic to estimate fragmentation of the pool.
|
static |
Free an allocation and its associated client. It doesn't need to be resident in this pool.
uint64 FFixedAllocMemoryPool::FreeAllEmptyArenas | ( | ) |
Free all arenas that are empty.
uint64 FFixedAllocMemoryPool::FreeEmptyArenasAccordingToPredicate | ( | std::function< bool() > | iPredicate | ) |
Free arenas according to predicate.
uint64 FFixedAllocMemoryPool::FreeEmptyArenasToReachTargetMemory | ( | ) |
Free all arenas that are empty.
byte_t FFixedAllocMemoryPool::FreeMemory | ( | ) | const |
Obtain current free memory as bytes.
bool FFixedAllocMemoryPool::FreeOneArenaIfNecessary | ( | ) |
Delete empty arena page if target memory is reached.
tClient FFixedAllocMemoryPool::Malloc | ( | ) |
Obtain an client to an allocation within this pool. If full or a failure occurs, returns nullptr.
FMemoryPoolPolicy& FFixedAllocMemoryPool::MemoryPolicy | ( | ) |
Get modifiable Memory Policy.
const FMemoryPoolPolicy& FFixedAllocMemoryPool::MemoryPolicy | ( | ) | const |
Get const Memory Policy.
uint64 FFixedAllocMemoryPool::NumCells | ( | ) | const |
Obtain the number of total possible cells in the pool.
uint64 FFixedAllocMemoryPool::NumFreeCells | ( | ) | const |
Obtain the number of currently free cells in the pool.
uint64 FFixedAllocMemoryPool::NumUsedCells | ( | ) | const |
Obtain the number of currently used cells in the pool.
|
delete |
Explicitely deleted copy assignment operator
void FFixedAllocMemoryPool::SetDefragThreshold | ( | ufloat | iValue | ) |
Set the defrag theshold.
void FFixedAllocMemoryPool::SetTargetMemoryUsage | ( | byte_t | iValue | ) |
Set the target memory usage as bytes.
byte_t FFixedAllocMemoryPool::TargetMemoryUsage | ( | ) | const |
Obtain the target memory usage as bytes.
byte_t FFixedAllocMemoryPool::TotalMemory | ( | ) | const |
Obtain the total theoretical memory for this pool as bytes, given the current number or arenas.
void FFixedAllocMemoryPool::UnsafeFreeAll | ( | ) |
Free all resident allocations in this pool. Clients are deleted and not notified about their status. This is unsafe and dangerous, unless you're done with all clients.
byte_t FFixedAllocMemoryPool::UsedMemory | ( | ) | const |
Obtain current used memory as bytes.