MemoryPoolBlock Class

Block tracking object used by the byte buffer memory pool. A slab is a large allocation which is divided into smaller blocks. The individual blocks are then treated as independant array segments.

Namespace
Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure
Assemblies
  • Microsoft.AspNetCore.Server.Kestrel

Syntax

public class MemoryPoolBlock
class Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPoolBlock

Methods

Finalize()
protected void Finalize()
GetIterator()

acquires a cursor pointing into this block at the Start of “active” byte information

Return type:Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPoolIterator
public MemoryPoolIterator GetIterator()
Reset()

called when the block is returned to the pool. mutable values are re-assigned to their guaranteed initialized state.

public void Reset()
ToString()

ToString overridden for debugger convenience. This displays the “active” byte information in this block as ASCII characters.

Return type:System.String
public override string ToString()

Constructors

MemoryPoolBlock(System.IntPtr)

This object cannot be instantiated outside of the static Create method

protected MemoryPoolBlock(IntPtr dataArrayPtr)

Properties

Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPoolBlock.Array

Convenience accessor

Return type:System.Byte<System.Byte>[]
public byte[] Array { get; }
Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPoolBlock.Pool

Back-reference to the memory pool which this block was allocated from. It may only be returned to this pool.

Return type:Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPool
public MemoryPool Pool { get; }
Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPoolBlock.Slab

Back-reference to the slab from which this block was taken, or null if it is one-time-use memory.

Return type:Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPoolSlab
public MemoryPoolSlab Slab { get; }

Fields

Data()

The array segment describing the range of memory this block is tracking. The caller which has leased this block may only read and modify the memory in this range.

Return type:System.ArraySegment<System.Byte>
public ArraySegment<byte> Data
DataArrayPtr()

Native address of the first byte of this block’s Data memory. It is null for one-time-use memory, or copied from the Slab’s ArrayPtr for a slab-block segment. The byte it points to corresponds to Data.Array[0], and in practice you will always use the DataArrayPtr + Start or DataArrayPtr + End, which point to the start of “active” bytes, or point to just after the “active” bytes.

Return type:System.IntPtr
public readonly IntPtr DataArrayPtr
End()

The End represents the offset into Array where the range of “active” bytes ends. At the point when the block is leased the End is guaranteed to be equal to Array.Offset. The value of Start may be assigned anywhere between Data.Offset and Data.Offset + Data.Count, and must be equal to or less than End.

Return type:System.Int32
public volatile int End
Next()

Reference to the next block of data when the overall “active” bytes spans multiple blocks. At the point when the block is leased Next is guaranteed to be null. Start, End, and Next are used together in order to create a linked-list of discontiguous working memory. The “active” memory is grown when bytes are copied in, End is increased, and Next is assigned. The “active” memory is shrunk when bytes are consumed, Start is increased, and blocks are returned to the pool.

Return type:Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.MemoryPoolBlock
public MemoryPoolBlock Next
Start()

The Start represents the offset into Array where the range of “active” bytes begins. At the point when the block is leased the Start is guaranteed to be equal to Array.Offset. The value of Start may be assigned anywhere between Data.Offset and Data.Offset + Data.Count, and must be equal to or less than End.

Return type:System.Int32
public int Start