Show / Hide Table of Contents

Class UnmanagedMemoryPool<T>

Represents pool of unmanaged memory.

Inheritance
object
MemoryPool<T>
UnmanagedMemoryPool<T>
Implements
IDisposable
Inherited Members
MemoryPool<T>.Dispose()
MemoryPool<T>.Shared
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Namespace: DotNext.Buffers
Assembly: DotNext.Unsafe.dll
Syntax
public sealed class UnmanagedMemoryPool<T> : MemoryPool<T>, IDisposable where T : unmanaged
Type Parameters
Name Description
T

The type of the items in the memory pool.

Constructors

| Edit this page View Source

UnmanagedMemoryPool(int)

Initializes a new pool of unmanaged memory.

Declaration
public UnmanagedMemoryPool(int maxBufferSize)
Parameters
Type Name Description
int maxBufferSize

The maximum allowed number of elements that can be allocated by the pool.

Exceptions
Type Condition
ArgumentOutOfRangeException

maxBufferSize is negative or zero.

Properties

| Edit this page View Source

AllocateZeroedMemory

Sets a value indicating that the allocated unmanaged memory must be filled with zeroes.

Declaration
public bool AllocateZeroedMemory { init; }
Property Value
Type Description
bool
| Edit this page View Source

DefaultBufferSize

Gets or sets the size of memory block allocated by default.

Declaration
public int DefaultBufferSize { get; init; }
Property Value
Type Description
int
| Edit this page View Source

MaxBufferSize

Gets the maximum elements that can be allocated by this pool.

Declaration
public override int MaxBufferSize { get; }
Property Value
Type Description
int
Overrides
MemoryPool<T>.MaxBufferSize
| Edit this page View Source

TrackAllocations

Indicates that destruction of this pool releases the memory rented by this pool.

Declaration
public bool TrackAllocations { get; init; }
Property Value
Type Description
bool

true to release allocated unmanaged memory when Dispose(bool) is called; otherwise, false.

Methods

| Edit this page View Source

Dispose(bool)

Frees the unmanaged resources used by the memory pool and optionally releases the managed resources.

Declaration
protected override void Dispose(bool disposing)
Parameters
Type Name Description
bool disposing

true to release both managed and unmanaged resources; false to release only unmanaged resources.

Overrides
MemoryPool<T>.Dispose(bool)
| Edit this page View Source

Rent(int)

Returns unmanaged memory block capable of holding at least length elements of T.

Declaration
public override IMemoryOwner<T> Rent(int length = -1)
Parameters
Type Name Description
int length

The length of the continuous block of memory.

Returns
Type Description
IMemoryOwner<T>

The allocated block of unmanaged memory.

Overrides
MemoryPool<T>.Rent(int)
Exceptions
Type Condition
ArgumentOutOfRangeException

length is greater than MaxBufferSize.

Implements

IDisposable

Extension Methods

BasicExtensions.As<T>(T)
BasicExtensions.GetUserData<T>(T)
BasicExtensions.IsBetween<T, TLowerBound, TUpperBound>(T, TLowerBound, TUpperBound)
BasicExtensions.IsOneOf<T>(T, ReadOnlySpan<T>)
ExpressionBuilder.Const<T>(T)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, bool, TimeSpan, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan, CancellationToken)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
Memory.ToAllocator<T>(MemoryPool<T>)
  • Edit this page
  • View Source
☀
☾
In this article
Back to top
Supported by the .NET Foundation
☀
☾