Table of Contents

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

context CudaContext

The context.

device CudaDevice

The device.

logger ILogger

The logger.

Properties

PoolHitRate

Gets the pool hit rate (efficiency metric).

public double PoolHitRate { get; }

Property Value

double

TotalBytesAllocated

Gets the total bytes allocated through the pool manager.

public long TotalBytesAllocated { get; }

Property Value

long

TotalBytesInPools

Gets the total bytes currently in pools.

public long TotalBytesInPools { get; }

Property Value

long

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

sizeInBytes long
zeroMemory bool
cancellationToken CancellationToken

Returns

Task<IPooledMemoryBuffer>

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()

Returns

MemoryPoolStatistics