Add TLSF allocator and refactor allocation API

- Introduced TLSF allocator with thread-safe wrapper and integrated into AllocationManager.
- Extended AllocationManagerDesc for TLSF config; made properties settable.
- Refactored AllocationHandle to encapsulate function pointers and state, replacing direct field access with methods.
- Updated all memory-related structs to use new AllocationHandle API.
- Added ReplaceIfZeros utility to MemoryUtility.
- Improved IndexOfNullByte performance.
- Minor fix in MemoryLeakException output order.
- FreeList now uses a fixed 64KB refill budget.
- Bumped version to 1.6.21; removed MHP_ENABLE_STACKTRACE from Debug.
- Updated Program.cs to test TLSF allocator and manage allocation lifecycle.
This commit is contained in:
2026-05-05 22:13:58 +09:00
parent 627c1da928
commit d3e497c7d8
14 changed files with 303 additions and 114 deletions

View File

@@ -422,8 +422,8 @@ public unsafe struct FreeList : IMemoryAllocator<FreeList, FreeList.CreationOpti
}
var blockSize = bucket->blockSize;
var blocksToCreate = Math.Max(1u, _chunkSize / blockSize);
blocksToCreate = Math.Min(blocksToCreate, 256);
const nuint REFILL_BUDGET = 64 * 1024; // 64KB per refill
var blocksToCreate = Math.Max(1u, REFILL_BUDGET / blockSize);
if (blocksToCreate == 0)
{