Class UnmanagedMemoryPool<T>
Represents pool of unmanaged memory.
Implements
Inherited Members
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 SourceUnmanagedMemoryPool(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 |
|
Properties
| Edit this page View SourceAllocateZeroedMemory
Sets a value indicating that the allocated unmanaged memory must be filled with zeroes.
Declaration
public bool AllocateZeroedMemory { init; }
Property Value
| Type | Description |
|---|---|
| bool |
DefaultBufferSize
Gets or sets the size of memory block allocated by default.
Declaration
public int DefaultBufferSize { get; init; }
Property Value
| Type | Description |
|---|---|
| int |
MaxBufferSize
Gets the maximum elements that can be allocated by this pool.
Declaration
public override int MaxBufferSize { get; }
Property Value
| Type | Description |
|---|---|
| int |
Overrides
| Edit this page View SourceTrackAllocations
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 SourceDispose(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
| Edit this page View SourceRent(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
Exceptions
| Type | Condition |
|---|---|
| ArgumentOutOfRangeException |
|