feat(allocator): add VirtualArena and FreeList allocators

Introduce VirtualArena for large, thread-safe virtual memory allocation and FreeList allocator for efficient persistent allocations. Update AllocationManager to support new allocators, add cross-platform virtual memory utilities, and improve thread-safety and performance in existing allocators. Bump version to 1.5.0 and update project configuration.

BREAKING CHANGE: AllocationManager initialization now requires explicit parameters for arena and FreeList capacities. Existing allocator usage may require code changes.
This commit is contained in:
2026-03-18 19:26:16 +09:00
parent 9cee32aa83
commit 7326c83948
12 changed files with 425 additions and 64 deletions

View File

@@ -206,11 +206,15 @@ public unsafe struct UnsafeList<T> : IUnsafeCollection<T>
{
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Conditional("ENABLE_COLLECTION_CHECKS")]
private readonly void CheckNoResizeCapacity(int count)
{
CheckNoResizeCapacity(count, Count);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Conditional("ENABLE_COLLECTION_CHECKS")]
private readonly void CheckNoResizeCapacity(int index, int count)
{
if (index + count > Capacity)
@@ -242,16 +246,19 @@ public unsafe struct UnsafeList<T> : IUnsafeCollection<T>
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Enumerator GetEnumerator()
{
return new((UnsafeList<T>*)UnsafeUtility.AddressOf(ref this));
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
IEnumerator<T> IEnumerable<T>.GetEnumerator()
{
return GetEnumerator();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
@@ -266,6 +273,7 @@ public unsafe struct UnsafeList<T> : IUnsafeCollection<T>
/// Otherwise the parallel reader will be invalid after the stack frame that creates the list is popped, even if the list's internal array is still valid.
/// </remarks>
/// <returns>A <see cref="ParallelReader"/> instance that can be used to read items from the list in a thread-safe manner.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ParallelReader AsParallelReader()
{
return new((UnsafeList<T>*)UnsafeUtility.AddressOf(ref this));
@@ -280,6 +288,7 @@ public unsafe struct UnsafeList<T> : IUnsafeCollection<T>
/// Otherwise the parallel writer will be invalid after the stack frame that creates the list is popped, even if the list's internal array is still valid.
/// </remarks>
/// <returns>A <see cref="ParallelWriter"/> instance that can be used to add items to the list in a thread-safe manner.</returns>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public ParallelWriter AsParallelWriter()
{
return new((UnsafeList<T>*)UnsafeUtility.AddressOf(ref this));