feat(memory): refactor allocation and add new queue
Refactored memory management by removing safety checks and introducing `MemoryHandle` for centralized tracking. Simplified allocation logic across allocators and enhanced `Dispose` methods for better resource cleanup. Added `UnsafeChunkedQueue<T>`, a lock-free, dynamically resizing queue with chunk-based memory management, supporting parallel producers and consumers. Updated unit tests to validate new queue functionality and ensure compatibility with refactored memory logic. Incremented assembly version to 1.6.12. BREAKING CHANGE: Removed `#if MHP_ENABLE_SAFETY_CHECKS` blocks, altering memory validation behavior.
This commit is contained in:
@@ -183,7 +183,12 @@ public unsafe struct DynamicArena : IMemoryAllocator<DynamicArena, DynamicArena.
|
||||
return;
|
||||
}
|
||||
|
||||
var current = _root;
|
||||
var ptr = _root;
|
||||
|
||||
_root = null;
|
||||
_current = null;
|
||||
|
||||
var current = ptr;
|
||||
while (current != null)
|
||||
{
|
||||
var next = current->next;
|
||||
@@ -191,8 +196,5 @@ public unsafe struct DynamicArena : IMemoryAllocator<DynamicArena, DynamicArena.
|
||||
MemoryUtility.Free(current);
|
||||
current = next;
|
||||
}
|
||||
|
||||
_root = null;
|
||||
_current = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user