Show / Hide Table of Contents

Class UnmanagedMemoryPool<T>

Represents pool of unmanaged memory,

Inheritance
Object
UnmanagedMemoryPool<T>
Namespace: DotNext.Buffers
Assembly: DotNext.Unsafe.dll
Syntax
public sealed class UnmanagedMemoryPool<T> : MemoryPool<T> where T : struct
Type Parameters
Name Description
T

The type of the items in the memory pool.

Constructors

| Improve this Doc View Source

UnmanagedMemoryPool(Int32, Int32, Boolean)

Initializes a new pool of unmanaged memory.

Declaration
public UnmanagedMemoryPool(int maxBufferSize, int defaultBufferSize = 32, bool trackAllocations = false)
Parameters
Type Name Description
Int32 maxBufferSize

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

Int32 defaultBufferSize

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

Boolean trackAllocations

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

Properties

| Improve this Doc View Source

MaxBufferSize

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

Declaration
public override int MaxBufferSize { get; }
Property Value
Type Description
Int32

Methods

| Improve this Doc View Source

Allocate(Int32, Boolean)

Allocates unmanaged memory and returns an object that controls its lifetime.

Declaration
public static IUnmanagedMemoryOwner<T> Allocate(int length, bool zeroMem = true)
Parameters
Type Name Description
Int32 length

The number of elements to be allocated in unmanaged memory.

Boolean zeroMem

true to set all bits in the memory to zero; otherwise, false.

Returns
Type Description
IUnmanagedMemoryOwner<T>

The object representing allocated unmanaged memory.

| Improve this Doc View Source

Dispose(Boolean)

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
Boolean disposing

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

| Improve this Doc View Source

Rent(Int32)

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

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

The length of the continuous block of memory.

Returns
Type Description
IMemoryOwner<T>

The allocated block of unmanaged memory.

Extension Methods

AsyncLockAcquisition.AcquireLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireReadLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireWriteLockAsync<T>(T, CancellationToken)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, TimeSpan)
AsyncLockAcquisition.AcquireUpgradeableReadLockAsync<T>(T, CancellationToken)
ExpressionBuilder.Const<T>(T)
ObjectExtensions.GetUserData<T>(T)
ObjectExtensions.IsOneOf<T>(T, IEnumerable<T>)
ObjectExtensions.IsOneOf<T>(T, T[])
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>, out R1, out R2)
ObjectExtensions.Decompose<T, R1, R2>(T, Func<T, R1>, Func<T, R2>)
ObjectExtensions.Decompose<T, R1, R2>(T, ValueFunc<T, R1>, ValueFunc<T, R2>)
LockAcquisition.AcquireReadLock<T>(T)
LockAcquisition.AcquireReadLock<T>(T, TimeSpan)
LockAcquisition.AcquireWriteLock<T>(T)
LockAcquisition.AcquireWriteLock<T>(T, TimeSpan)
LockAcquisition.AcquireUpgradeableReadLock<T>(T)
LockAcquisition.AcquireUpgradeableReadLock<T>(T, TimeSpan)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX