Class CudaMemoryPoolManager
- Namespace
- DotCompute.Backends.CUDA.Memory
- Assembly
- DotCompute.Backends.CUDA.dll
Manages memory pools for efficient allocation and reuse of CUDA memory. Reduces allocation overhead and memory fragmentation.
public sealed class CudaMemoryPoolManager : IDisposable
- Inheritance
-
CudaMemoryPoolManager
- Implements
- Inherited Members
- Extension Methods
Constructors
CudaMemoryPoolManager(CudaContext, CudaDevice, ILogger)
Initializes a new instance of the CudaMemoryPoolManager class.
public CudaMemoryPoolManager(CudaContext context, CudaDevice device, ILogger logger)
Parameters
contextCudaContextThe context.
deviceCudaDeviceThe device.
loggerILoggerThe logger.
Properties
PoolHitRate
Gets the pool hit rate (efficiency metric).
public double PoolHitRate { get; }
Property Value
TotalBytesAllocated
Gets the total bytes allocated through the pool manager.
public long TotalBytesAllocated { get; }
Property Value
TotalBytesInPools
Gets the total bytes currently in pools.
public long TotalBytesInPools { get; }
Property Value
Methods
AllocateAsync(long, bool, CancellationToken)
Allocates memory from the pool or creates new allocation if pool is empty.
public Task<IPooledMemoryBuffer> AllocateAsync(long sizeInBytes, bool zeroMemory = false, CancellationToken cancellationToken = default)
Parameters
sizeInByteslongzeroMemoryboolcancellationTokenCancellationToken
Returns
ClearPools()
Clears all pools and frees memory.
public void ClearPools()
Dispose()
Performs dispose.
public void Dispose()
GetStatistics()
Gets pool statistics for monitoring.
public MemoryPoolStatistics GetStatistics()