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:
@@ -719,6 +719,7 @@ public unsafe struct HashMapHelper<TKey> : IDisposable
|
||||
{
|
||||
if (!IsCreated)
|
||||
{
|
||||
Debug.Fail("The UnsafeArray is not created or already disposed.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -418,6 +418,7 @@ public unsafe struct UnsafeArray<T> : IUnsafeCollection<T>
|
||||
{
|
||||
if (!IsCreated)
|
||||
{
|
||||
Debug.Fail("The UnsafeArray is not created or already disposed.");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user