feat(buffer): add allocation tracking and diagnostics

Add AllocationManager.GetTotalAllocatedMemory() to track total allocations when safety checks are enabled. Improve diagnostics by calling Debug.Fail in Dispose methods of HashMapHelper, UnTypedArray, and UnsafeArray when disposing uninitialized or already disposed arrays. Remove AddRange(ReadOnlyUnsafeCollection<T>) from UnsafeList<T>. Increment assembly version to 1.6.4. Ensure arrcpy is disposed in Program.cs.
This commit is contained in:
2026-04-02 19:11:37 +09:00
parent 299426b48b
commit 78c565e428
7 changed files with 32 additions and 10 deletions

View File

@@ -719,6 +719,7 @@ public unsafe struct HashMapHelper<TKey> : IDisposable
{
if (!IsCreated)
{
Debug.Fail("The UnsafeArray is not created or already disposed.");
return;
}

View File

@@ -1,6 +1,7 @@
using Misaki.HighPerformance.LowLevel.Buffer;
using Misaki.HighPerformance.LowLevel.Collections.Contracts;
using Misaki.HighPerformance.LowLevel.Utilities;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace Misaki.HighPerformance.LowLevel.Collections;
@@ -272,6 +273,7 @@ public unsafe struct UnTypedArray : IUnTypedCollection
{
if (!IsCreated)
{
Debug.Fail("The UnsafeArray is not created or already disposed.");
return;
}

View File

@@ -418,6 +418,7 @@ public unsafe struct UnsafeArray<T> : IUnsafeCollection<T>
{
if (!IsCreated)
{
Debug.Fail("The UnsafeArray is not created or already disposed.");
return;
}

View File

@@ -363,15 +363,6 @@ public unsafe struct UnsafeList<T> : IUnsafeCollection<T>
_count += values.Length;
}
/// <summary>
/// Adds a range of elements to the collection.
/// </summary>
/// <param name="values">A collection containing the elements to add.</param>
public void AddRange(ReadOnlyUnsafeCollection<T> collection)
{
AddRange((T*)collection.GetUnsafePtr(), collection.Count);
}
/// <summary>
/// Adds a range of elements from a pointer to the collection.
/// </summary>