feat(memory): transition to AllocationHandle API

Replaced the deprecated Allocator API with the new AllocationHandle API across the codebase. Updated constructors, methods, and tests to use AllocationHandle for memory management. Marked Allocator-based methods as [Obsolete] and provided alternatives.

Added OwnershipTransferAnalyzer to detect ownership transfer issues and introduced OwnershipTransferAttribute for marking parameters. Enhanced DefensiveCopyAnalyzer with additional checks for readonly and ValueType instances.

Refactored internal memory management in AllocationManager and updated benchmarks, utilities, and documentation to reflect the changes.

BREAKING CHANGE: Deprecated Allocator API in favor of AllocationHandle. Updated constructors and methods to use AllocationHandle. Users must migrate to the new API.
This commit is contained in:
2026-04-12 17:50:12 +09:00
parent a0deadc363
commit 9c4faa107a
40 changed files with 260 additions and 85 deletions

View File

@@ -76,6 +76,26 @@ public readonly struct MemoryHandle : IDisposable, IEquatable<MemoryHandle>
/// </summary>
public readonly unsafe struct AllocationHandle
{
/// <summary>
/// The invalid allocator. This value is reserved and should not be used for actual memory allocations. It can be used to indicate an uninitialized or invalid state in allocation scenarios.
/// </summary>
public static readonly AllocationHandle Invalid = default;
/// <summary>
/// Allocator for temporary allocations. Allocations are automatically released after use automatically.
/// </summary>
public static readonly AllocationHandle Temp = AllocationManager.s_arenaAllocator.AllocationHandle;
/// <summary>
/// Allocator for persistent allocations. Allocations are not automatically released after use.
/// </summary>
public static readonly AllocationHandle FreeList = AllocationManager.s_freeListAllocator.AllocationHandle;
/// <summary>
/// Allocator for persistent allocations using a free list. Allocations are not automatically released after use, but can be reused to reduce fragmentation, system call and improve performance.
/// </summary>
public static readonly AllocationHandle Persistent = AllocationManager.s_pHeapAllocator->Handle;
/// <summary>
/// Gets a pointer to the state instance associated with this allocation handle.
/// </summary>