Table of Contents

Class HighPerformanceObjectPool<T>

Namespace
DotCompute.Memory
Assembly
DotCompute.Memory.dll

High-performance object pool optimized for compute workloads with:

  • Lock-free operations using ConcurrentStack
  • Automatic pool size management
  • Thread-local storage for hot paths
  • Performance metrics and monitoring
  • Configurable eviction policies
  • NUMA-aware allocation when available Target: 90%+ allocation reduction for frequent operations
public sealed class HighPerformanceObjectPool<T> : ObjectPool<T>, IDisposable where T : class

Type Parameters

T

The type of objects to pool.

Inheritance
HighPerformanceObjectPool<T>
Implements
Inherited Members
Extension Methods

Constructors

HighPerformanceObjectPool(Func<T>, Action<T>?, Func<T, bool>?, PoolConfiguration?, ILogger?)

Initializes a new high-performance object pool.

public HighPerformanceObjectPool(Func<T> createFunc, Action<T>? resetAction = null, Func<T, bool>? validateFunc = null, PoolConfiguration? config = null, ILogger? logger = null)

Parameters

createFunc Func<T>

Function to create new objects.

resetAction Action<T>

Optional action to reset objects before reuse.

validateFunc Func<T, bool>

Optional function to validate objects before reuse.

config PoolConfiguration

Pool configuration settings.

logger ILogger

Optional logger for diagnostics.

Properties

Statistics

Gets pool performance statistics.

public PoolStatistics Statistics { get; }

Property Value

PoolStatistics

Methods

Dispose()

Performs dispose.

public void Dispose()

Get()

Gets an object from the pool with optimized thread-local caching.

public override T Get()

Returns

T

Return(T)

Returns an object to the pool with optimized thread-local caching.

public override void Return(T obj)

Parameters

obj T

TriggerMaintenance()

Forces pool maintenance (cleanup, resizing, etc.).

public void TriggerMaintenance()