Centralize memory ops via MemoryUtility, add VM support

Refactor all memory allocation/deallocation to use MemoryUtility, replacing direct calls with unified methods. Introduce cross-platform virtual memory management (Mmap, Munmap, Decommit, Recommit). Switch to NativeMemory for standard allocations. Enhance FreeList with global free buckets and thread safety. Standardize alignment/size calculations. Remove global usings for memory utils. Bump version to 1.6.24. Includes minor cleanups and improved docs.
This commit is contained in:
2026-05-07 21:34:25 +09:00
parent f8b11182a9
commit d2c165bbe5
21 changed files with 382 additions and 111 deletions

View File

@@ -1,5 +1,6 @@
using Misaki.HighPerformance.LowLevel.Utilities;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
namespace Misaki.HighPerformance.LowLevel.Buffer;
@@ -16,7 +17,7 @@ public unsafe struct MemoryPool<TAllocator, TOpts> : IDisposable
{
var allocator = TAllocator.Create(opts);
_pAllocator = (TAllocator*)Malloc((nuint)sizeof(TAllocator));
_pAllocator = (TAllocator*)NativeMemory.Alloc((nuint)sizeof(TAllocator));
*_pAllocator = allocator;
_allocationHandle = new AllocationHandle(_pAllocator, &Allocate, &Reallocate, &Free);
@@ -46,7 +47,7 @@ public unsafe struct MemoryPool<TAllocator, TOpts> : IDisposable
_pAllocator->Dispose();
MemoryUtility.Free(_pAllocator);
NativeMemory.Free(_pAllocator);
_pAllocator = null;
_allocationHandle = default;