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
TThe element type.
- Inheritance
-
AllocationTrackedMemoryManager<T>
- Implements
-
IMemoryOwner<T>
- 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
allocatorMemoryAllocatorThe allocator that owns the reservation for this instance.
lengthInByteslongThe 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
disposingbooltrue 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
Remarks
Implementations release their own resources here. Allocation tracking is released by the sealed base dispose path after this method returns.