public void Dispose() { if (m_Buffer == null) { throw new ObjectDisposedException("The NativeArray is already disposed."); } if (m_AllocatorLabel == Allocator.Invalid) { throw new InvalidOperationException("The NativeArray can not be Disposed because it was not allocated with a valid allocator."); } if (m_AllocatorLabel > Allocator.None) { AtomicSafetyHandle.DisposeHandle(ref m_Safety); UnsafeUtility.FreeTracked(m_Buffer, m_AllocatorLabel); m_AllocatorLabel = Allocator.Invalid; } m_Buffer = null; }