public unsafe JobHandle Dispose(JobHandle inputDeps) { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (!UnsafeUtility.IsValidAllocator(m_AllocatorLabel)) { throw new InvalidOperationException("The NativeArray can not be Disposed because it was not allocated with a valid allocator."); } // DisposeSentinel needs to be cleared on the main thread. DisposeSentinel.Clear(ref m_DisposeSentinel); #endif // Create a job to dispose of our container and pass a copy of our pointer to it. NativeIntArrayDisposeJob disposeJob = new NativeIntArrayDisposeJob() { Data = new NativeIntArrayDispose() { m_Buffer = m_Buffer, m_AllocatorLabel = m_AllocatorLabel } }; JobHandle result = disposeJob.Schedule(inputDeps); #if ENABLE_UNITY_COLLECTIONS_CHECKS AtomicSafetyHandle.Release(m_Safety); #endif m_Buffer = null; m_Length = 0; return(result); }
private void CheckAllocator() { if (!UnsafeUtility.IsValidAllocator(_alloc)) { throw new InvalidOperationException("The buffer can not be Disposed because it was not allocated with a valid allocator."); } }
private static void RequireValidAllocator(Allocator allocator) { if (!UnsafeUtility.IsValidAllocator(allocator)) { throw new InvalidOperationException("The NativeArray2D cannot be Disposed because it was not allocated with a valid allocator."); } }
public static void IsValidAllocatorAndThrow <Container>(Allocator allocator) where Container : struct { if (!UnsafeUtility.IsValidAllocator(allocator)) { throw new InvalidOperationException( $"The {typeof(Container)} can not be Disposed because it was not allocated with a valid allocator." ); } }
public void Dispose() { Assert.IsTrue(UnsafeUtility.IsValidAllocator(this.m_AllocatorLabel)); #if ENABLE_UNITY_COLLECTIONS_CHECKS DisposeSentinel.Dispose(ref this.m_Safety, ref this.m_DisposeSentinel); #endif UnsafeUtility.Free(this.m_Buffer, this.m_AllocatorLabel); this.m_Buffer = null; }
public void Dispose() { if (!UnsafeUtility.IsValidAllocator(m_AllocatorLabel)) { throw new InvalidOperationException("The NativeArray can not be Disposed because it was not allocated with a valid allocator."); } DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel); Deallocate(); }
private static void RequireValidAllocator(Allocator allocator) { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (!UnsafeUtility.IsValidAllocator(allocator)) { throw new InvalidOperationException( "The NativeArray2D can not be Disposed because it was " + "not allocated with a valid allocator."); } #endif }
public void Dispose() { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (!UnsafeUtility.IsValidAllocator(allocator)) { throw new InvalidOperationException("The NativeArray can not be Disposed because it was not allocated with a valid allocator."); } DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel); #endif UnsafeUtility.Free(buffer, allocator); }
/// <summary> /// Dispose of the heap by freeing up memory. /// </summary> /// <exception cref="InvalidOperationException"> Memory hasn't been allocated. </exception> public void Dispose() { if (!UnsafeUtility.IsValidAllocator(this.allocator)) { return; } #if ENABLE_UNITY_COLLECTIONS_CHECKS DisposeSentinel.Dispose(ref this.m_Safety, ref this.m_DisposeSentinel); #endif UnsafeUtility.Free(this.buffer, this.allocator); this.buffer = null; this.capacity = 0; }
public unsafe void Dispose() { if (!UnsafeUtility.IsValidAllocator(m_AllocatorLabel)) { throw new InvalidOperationException("The NativeArray2 can not be Disposed because it was not allocated with a valid allocator."); } // DisposeSentinel.Dispose(ref this.m_Safety, ref this.m_DisposeSentinel); UnsafeUtility.Free(m_Buffer, m_AllocatorLabel); m_Buffer = (void *)null; m_Length = 0; }
public void Dispose() { if (!UnsafeUtility.IsValidAllocator(m_AllocatorLabel)) { throw new InvalidOperationException("The NativeArray can not be Disposed because it was not allocated with a valid allocator."); } #if ENABLE_UNITY_COLLECTIONS_CHECKS DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel); #endif UnsafeUtility.Free(m_Buffer, m_AllocatorLabel); m_Buffer = null; m_capacity = 0; }
public unsafe void Dispose() { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (!UnsafeUtility.IsValidAllocator(m_AllocatorLabel)) { throw new InvalidOperationException("The ComponentTypeHandleArray can not be disposed because it was not allocated with a valid allocator."); } DisposeSentinel.Dispose(ref this.m_Safety, ref this.m_DisposeSentinel); #endif UnsafeUtility.Free(m_Buffer, m_AllocatorLabel); m_Buffer = (void *)null; m_Length = 0; }
public void Dispose() { if (!UnsafeUtility.IsValidAllocator(m_AllocatorLabel)) { throw new InvalidOperationException("The NativeDataResource can not be Disposed because it was not allocated with a valid allocator."); } UnsafeUtility.Free(m_Data, m_AllocatorLabel); m_Data = null; UnsafeUtility.Free(m_Table, m_AllocatorLabel); m_Table = null; UnsafeUtility.Free(m_Index, m_AllocatorLabel); m_Index = null; }
public void Dispose() { if (!UnsafeUtility.IsValidAllocator(m_AllocatorLabel)) { throw new InvalidOperationException("The NativeHeap can not be Disposed because it was not allocated with a valid allocator."); } DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel); UnsafeUtility.Free(m_HeapData->mBuffer, m_AllocatorLabel); UnsafeUtility.Free(m_HeapData, m_AllocatorLabel); m_HeapData->capacity = 0; m_HeapData->m_length = 0; m_HeapData->mBuffer = null; m_HeapData = null; }
public void Dispose() { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (!UnsafeUtility.IsValidAllocator(m_AllocatorLabel)) { throw new InvalidOperationException("The NativeSummedFloat3 can not be Disposed because it was not allocated with a valid allocator."); } DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel); #endif // Free the allocated memory and reset our variables. UnsafeUtility.Free(m_Buffer, m_AllocatorLabel); m_Buffer = null; }
public void Dispose() { if (Disposed) { return; } Disposed = true; #if ENABLE_UNITY_COLLECTIONS_CHECKS if (!UnsafeUtility.IsValidAllocator(Allocator)) { throw new InvalidOperationException("The NativeVariable can not be Disposed because it was not allocated with a valid allocator."); } #endif UnsafeUtility.Free(_addr, Allocator); _addr = null; }
public BarracudaArray(int length, DataType dataType = DataType.Float, Allocator allocator = Allocator.Persistent) { if (!UnsafeUtility.IsValidAllocator(allocator)) { throw new InvalidOperationException("The BarracudaArray should use a valid allocator."); } if (length < 0) { throw new ArgumentOutOfRangeException(nameof(length), "Length must be >= 0"); } m_DataType = dataType; m_Length = length; m_SafeHandle = new NativeMemorySafeHandle(LengthWithPaddingForGPUCopy(m_DataType, m_Length) * DataItemSize(dataType), DataAlignmentSize(dataType), allocator); m_Allocator = allocator; }
public void Dispose() { #if ENABLE_UNITY_COLLECTIONS_CHECKS if (!UnsafeUtility.IsValidAllocator(m_AllocatorLabel)) { throw new InvalidOperationException("The NativeBucket can not be Disposed because it was not allocated with a valid allocator."); } #if UNITY_2018_3_OR_NEWER DisposeSentinel.Dispose(ref m_Safety, ref m_DisposeSentinel); #else DisposeSentinel.Dispose(m_Safety, ref m_DisposeSentinel); #endif #endif for (int i = 0; i < JobsUtility.MaxJobThreadCount; ++i) { NativeBucketHeader *headerBlock = GetHeaderBlock(m_HeaderBlock, i); if (headerBlock->block != IntPtr.Zero) { UnsafeUtility.Free((void *)headerBlock->block, m_AllocatorLabel); } } UnsafeUtility.Free(m_HeaderBlock, m_AllocatorLabel); m_HeaderBlock = null; }