Class MemoryPoolService
- Namespace
- DotCompute.Runtime.Services
- Assembly
- DotCompute.Runtime.dll
Production implementation of memory pool service for efficient buffer reuse and management.
public sealed class MemoryPoolService : IMemoryPoolService, IDisposable
- Inheritance
-
MemoryPoolService
- Implements
- Inherited Members
- Extension Methods
Constructors
MemoryPoolService(ILogger<MemoryPoolService>)
Initializes a new instance of the MemoryPoolService class.
public MemoryPoolService(ILogger<MemoryPoolService> logger)
Parameters
loggerILogger<MemoryPoolService>The logger.
Methods
CreatePoolAsync(string, long, long)
Creates a new memory pool for an accelerator
public Task<IMemoryPool> CreatePoolAsync(string acceleratorId, long initialSize, long maxSize)
Parameters
acceleratorIdstringThe accelerator identifier
initialSizelongThe initial pool size in bytes
maxSizelongThe maximum pool size in bytes
Returns
- Task<IMemoryPool>
The created memory pool
Dispose()
Performs dispose.
public void Dispose()
GetPool(string)
Gets a memory pool for the specified accelerator
public IMemoryPool GetPool(string acceleratorId)
Parameters
acceleratorIdstringThe accelerator identifier
Returns
- IMemoryPool
The memory pool for the accelerator
GetUsageStatistics()
Gets memory usage statistics across all pools
public MemoryUsageStatistics GetUsageStatistics()
Returns
- MemoryUsageStatistics
Memory usage statistics
OptimizeMemoryUsageAsync()
Optimizes memory usage across all pools
public Task OptimizeMemoryUsageAsync()
Returns
- Task
A task representing the optimization operation
ReleaseUnusedMemoryAsync()
Releases unused memory from all pools
public Task<long> ReleaseUnusedMemoryAsync()