WIP: Removed internal header tracking for WorkspaceHeap. Modified Handles to track the alignment that the underlying memory was aligned to. Re-worked WorkspaceHeap to use lists rather than Stack

This commit is contained in:
Jim
2026-03-23 22:26:01 +00:00
parent c2150acb2c
commit f73c09add5
6 changed files with 215 additions and 138 deletions

View File

@@ -291,7 +291,7 @@
/// <exception cref="ArgumentException">
/// Thrown if <paramref name="segmentSize"/> is zero, or if <paramref name="initialSegments"/> is less than 1.
/// </exception>
public SegmentedPool(nuint segmentSize = _defaultSegmentSize, SegmentAlignment segmentAlignment = SegmentAlignment.Aligned32, int initialSegments = 4, bool zeroMemory = false)
public SegmentedPool(nuint segmentSize = _defaultSegmentSize, SegmentAlignment segmentAlignment = SegmentAlignment.Aligned16, int initialSegments = 4, bool zeroMemory = false)
: this(segmentSize, segmentAlignment, initialSegments, zeroMemory, new DefaultUnmanagedAllocator())
{
}
@@ -620,7 +620,9 @@
{
T* ptr = Alloc<T>(count);
nuint byteLength = (nuint)count * (nuint)sizeof(T);
return new SegmentedMemoryHandle<T>(ptr, byteLength, this);
nuint alignment = _segmentAlignment > (nuint)sizeof(T) ? _segmentAlignment : (nuint)sizeof(T);
return new SegmentedMemoryHandle<T>(ptr, byteLength, alignment, this);
}
/// <summary>
@@ -651,7 +653,7 @@
T* ptr = AllocateWithAlignment<T>(count, effectiveAlignment);
nuint byteLength = (nuint)count * (nuint)sizeof(T);
return new SegmentedMemoryHandle<T>(ptr, byteLength, this);
return new SegmentedMemoryHandle<T>(ptr, byteLength, effectiveAlignment, this);
}