Class MemoryPool<T>
Represents a pool of MemoryPoolToken<T> instances.
public sealed class MemoryPool<T>
Type Parameters
T
Element type.
- Inheritance
-
MemoryPool<T>
- Inherited Members
- Extension Methods
Constructors
MemoryPool(int)
Creates a new MemoryPool<T> instance.
public MemoryPool(int minSegmentLength)
Parameters
minSegmentLength
intMinimum single pool segment length. The actual value will be rounded up to a power of two.
Properties
Report
Creates a new MemoryPool<T>.ReportInfo instance.
public MemoryPool<T>.ReportInfo Report { get; }
Property Value
SegmentLength
Length of a single pool segment.
public int SegmentLength { get; }
Property Value
Methods
GreedyRent(int)
Creates a new MemoryPoolToken<T> instance from this pool.
public MemoryPoolToken<T> GreedyRent(int length)
Parameters
length
intSize of the rented buffer.
Returns
- MemoryPoolToken<T>
New MemoryPoolToken<T> instance, or Empty when
length
is less than 1.
Remarks
This method always uses or allocates segments at the tail of the pool.
Rent(int)
Creates a new MemoryPoolToken<T> instance from this pool.
public MemoryPoolToken<T> Rent(int length)
Parameters
length
intSize of the rented buffer.
Returns
- MemoryPoolToken<T>
New MemoryPoolToken<T> instance, or Empty when
length
is less than 1.
Remarks
This method attempts to reuse fragmented segments.
TrimExcess()
Attempts to deallocate unused segments at the tail of this pool.
public void TrimExcess()