Class MemoryPoolManager
Memory pool manager for different types with size limits
public sealed class MemoryPoolManager : IDisposable
- Inheritance
-
MemoryPoolManager
- Implements
- Inherited Members
Constructors
MemoryPoolManager(ILoggerFactory, MemoryPoolOptions?)
Initializes a new instance of the MemoryPoolManager class.
public MemoryPoolManager(ILoggerFactory loggerFactory, MemoryPoolOptions? options = null)
Parameters
loggerFactoryILoggerFactoryThe logger factory for creating diagnostic loggers.
optionsMemoryPoolOptionsOptional memory pool configuration options.
Methods
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetAllStats()
Gets statistics for all memory pools.
public Dictionary<Type, MemoryPoolStats> GetAllStats()
Returns
- Dictionary<Type, MemoryPoolStats>
A dictionary mapping element types to their pool statistics.
GetHealthStatus()
Gets the current health status of the memory pool system.
public MemoryPoolHealth GetHealthStatus()
Returns
- MemoryPoolHealth
The health status information.
GetPool<T>()
Gets or creates a memory pool for the specified element type.
public IGpuMemoryPool<T> GetPool<T>() where T : unmanaged
Returns
- IGpuMemoryPool<T>
A memory pool for the specified type.
Type Parameters
TThe unmanaged element type.
ReleaseAllocation(long)
Releases a previously allocated number of bytes back to the pool.
public void ReleaseAllocation(long bytes)
Parameters
byteslongThe number of bytes to release.
TryAllocate(long, out string?)
Attempts to allocate the specified number of bytes from the total memory pool.
public bool TryAllocate(long requestedBytes, out string? reason)
Parameters
requestedByteslongThe number of bytes to allocate.
reasonstringIf allocation fails, contains the reason for failure.
Returns
- bool
True if allocation succeeded; otherwise, false.
UpdateLimits(long)
Updates the total memory limit for all pools.
public void UpdateLimits(long newTotalLimit)
Parameters
newTotalLimitlongThe new total memory limit in bytes.