Table of Contents

Class AllocationTrackedMemoryManager<T>

Namespace
SixLabors.ImageSharp.Memory
Assembly
SixLabors.ImageSharp.dll

Provides the tracked memory-owner contract required by MemoryAllocator.

public abstract class AllocationTrackedMemoryManager<T> : MemoryManager<T>, IMemoryOwner<T>, IDisposable, IPinnable where T : struct

Type Parameters

T

The element type.

Inheritance
AllocationTrackedMemoryManager<T>
Implements
Inherited Members

Remarks

Custom allocators implement AllocateCore<T>(int, AllocationOptions) and return a derived type. The base allocator attaches allocation tracking after the owner has been created so custom implementations cannot forget, duplicate, or mismatch the reservation lifecycle.

Methods

AttachAllocationTracking(MemoryAllocator, long)

Attaches allocation tracking to this owner after allocation has succeeded.

protected virtual void AttachAllocationTracking(MemoryAllocator allocator, long lengthInBytes)

Parameters

allocator MemoryAllocator

The allocator that owns the reservation for this instance.

lengthInBytes long

The reserved allocation size, in bytes.

Remarks

MemoryAllocator calls this exactly once after AllocateCore returns. Derived allocators should not call it themselves; they only construct the concrete owner.

Dispose(bool)

Releases all resources used by the current memory manager.

protected override sealed void Dispose(bool disposing)

Parameters

disposing bool

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

DisposeCore(bool)

Releases resources held by the concrete tracked owner.

protected abstract void DisposeCore(bool disposing)

Parameters

disposing bool

true when the owner is being disposed deterministically; otherwise, false.

Remarks

Implementations release their own resources here. Allocation tracking is released by the sealed base dispose path after this method returns.