public void Dispose() { for (var i = 0; i < m_DependencyHandlesCount; i++) { m_DependencyHandles[i].WriteFence.Complete(); } for (var i = 0; i < m_DependencyHandlesCount * kMaxReadJobHandles; i++) { m_ReadJobFences[i].Complete(); } Memory.Unmanaged.Free(m_JobDependencyCombineBuffer, Allocator.Persistent); Memory.Unmanaged.Free(m_TypeArrayIndices, Allocator.Persistent); Memory.Unmanaged.Free(m_DependencyHandles, Allocator.Persistent); m_DependencyHandles = null; Memory.Unmanaged.Free(m_ReadJobFences, Allocator.Persistent); m_ReadJobFences = null; #if ENABLE_UNITY_COLLECTIONS_CHECKS Safety.Dispose(); #endif }
public void OnCreate(WorldUnmanaged world) { m_World = world; m_TypeArrayIndices = (ushort *)Memory.Unmanaged.Allocate(sizeof(ushort) * kMaxTypes, 16, Allocator.Persistent); UnsafeUtility.MemSet(m_TypeArrayIndices, 0xFF, sizeof(ushort) * kMaxTypes); m_ReadJobFences = (JobHandle *)Memory.Unmanaged.Allocate(sizeof(JobHandle) * kMaxReadJobHandles * kMaxTypes, 16, Allocator.Persistent); UnsafeUtility.MemClear(m_ReadJobFences, sizeof(JobHandle) * kMaxReadJobHandles * kMaxTypes); m_DependencyHandles = (DependencyHandle *)Memory.Unmanaged.Allocate(sizeof(DependencyHandle) * kMaxTypes, 16, Allocator.Persistent); UnsafeUtility.MemClear(m_DependencyHandles, sizeof(DependencyHandle) * kMaxTypes); m_JobDependencyCombineBufferCount = 4 * 1024; m_JobDependencyCombineBuffer = (JobHandle *)Memory.Unmanaged.Allocate(sizeof(DependencyHandle) * m_JobDependencyCombineBufferCount, 16, Allocator.Persistent); m_DependencyHandlesCount = 0; _IsInTransaction = false; IsInForEachDisallowStructuralChange = 0; m_ExclusiveTransactionDependency = default; #if ENABLE_UNITY_COLLECTIONS_CHECKS Safety.OnCreate(); #endif m_Marker = new ProfilerMarker("CompleteAllJobs"); }