Class AdvancedMemoryPool<T>
Advanced memory pool with allocation tracking and statistics
public sealed class AdvancedMemoryPool<T> : IGpuMemoryPool<T>, IDisposable where T : unmanaged
Type Parameters
T
- Inheritance
-
AdvancedMemoryPool<T>
- Implements
- Inherited Members
Constructors
AdvancedMemoryPool(ILogger<AdvancedMemoryPool<T>>, int, int)
Initializes a new instance of the AdvancedMemoryPool<T> class
public AdvancedMemoryPool(ILogger<AdvancedMemoryPool<T>> logger, int maxBufferSize = 16777216, int maxPooledBuffers = 100)
Parameters
loggerILogger<AdvancedMemoryPool<T>>Logger instance for diagnostics
maxBufferSizeintMaximum size of buffers in the pool (default: 16MB)
maxPooledBuffersintMaximum number of buffers to maintain in the pool (default: 100)
Methods
Dispose()
Disposes the memory pool and releases all resources
public void Dispose()
GetStats()
Gets current statistics about the memory pool
public MemoryPoolStats GetStats()
Returns
- MemoryPoolStats
Memory pool statistics including allocation and usage information
Rent(int)
Rents a memory segment from the pool with at least the specified size
public IGpuMemory<T> Rent(int minSize)
Parameters
minSizeintMinimum size of the memory segment in elements
Returns
- IGpuMemory<T>
A pooled GPU memory instance
Return(IGpuMemory<T>)
Returns a memory segment to the pool for reuse
public void Return(IGpuMemory<T> memory)
Parameters
memoryIGpuMemory<T>The memory instance to return