Update memory management and collection structures

Added `AllocationHandler` struct for memory allocation management.
Added `UnsafeArrayPool` class for pooling `UnsafeArray<T>` instances.
Added new `External` option to `Allocator` enum.
Added default constructors for `UnsafeList`, `UnsafeQueue`, and `UnsafeStack` using `Persistent` allocator.
Changed namespace in `AllocationManager` to `Misaki.HighPerformance.Unsafe.Buffer`.
Changed `MemoryLeakException` to use `MemoryLeakExceptionInfo` for better debugging.
Changed constructor behavior in `UnsafeArray` to clarify memory management responsibilities.
Changed `MemoryUtilities` to include null checks in `Free` and `AlignedFree` methods.
Removed unused using directive in `CollectionBenchmark.cs`.
Removed initialization of `AllocationManager` in `Program.cs`.
This commit is contained in:
2025-04-05 16:07:04 +09:00
parent 9eea53d8f1
commit 463735a481
15 changed files with 177 additions and 53 deletions

View File

@@ -1,6 +1,6 @@
using BenchmarkDotNet.Attributes;
using Misaki.HighPerformance.Unsafe.Buffer;
using Misaki.HighPerformance.Unsafe.Collections;
using Misaki.HighPerformance.Unsafe.Services;
namespace Misaki.HighPerformance.Test;

View File

@@ -1,9 +1,10 @@
using Misaki.HighPerformance.Unsafe.Collections;
using Misaki.HighPerformance.Unsafe.Services;
using Misaki.HighPerformance.Unsafe.Helpers;
using System.Numerics;
AllocationManager.Initialize(100);
var unfreeArray = new UnsafeArray<int>(10, Allocator.Persistent);
var unfreeList = new UnsafeList<int>(10, Allocator.Persistent);
//unfreeArray.Dispose();
AllocationManager.Dispose();
unsafe
{
Console.WriteLine(sizeof(UnsafeHashMap<int, float>));
Console.WriteLine(MemoryUtilities.AlignOf<UnsafeHashMap<int, float>>());
Console.WriteLine(1 << Math.Min(3, BitOperations.TrailingZeroCount(sizeof(UnsafeHashMap<int, float>))));
}