public void Dispose()
        {
            UnsafeUtility.LeakErase(m_TransformArray, LeakCategory.TransformAccessArray);
            AtomicSafetyHandle.DisposeHandle(ref m_Safety);

            DestroyTransformAccessArray(m_TransformArray);
            m_TransformArray = IntPtr.Zero;
        }
        public void Dispose()
        {
            // When the NavMesh destroys itself it will disable read or write access.
            // Since it has been deallocated, we shouldn't deregister the query from it...
            // We need to extract removeQuery before disposing the handle,
            // because the atomic safety handle stores that state.
            var removeQuery = AtomicSafetyHandle.GetAllowReadOrWriteAccess(m_Safety);

            AtomicSafetyHandle.DisposeHandle(ref m_Safety);

            if (removeQuery)
            {
                RemoveQuerySafety(m_NavMeshQuery, m_Safety);
            }
            UnsafeUtility.LeakErase(m_NavMeshQuery, LeakCategory.NavMeshQuery);
            Destroy(m_NavMeshQuery);
            m_NavMeshQuery = IntPtr.Zero;
        }
        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;
        }