Open OtakuAndFitness opened 1 week ago
我把 JobHandle.ScheduleBatchedJobs();改成m_lastJobHandle.Complete()就会减少报错,但实例化很多个模型后,关闭运行并再次启动的时候还是会报错: A Native Collection has not been disposed, resulting in a memory leak. Allocated from: Unity.Collections.NativeArray`1:.ctor(Int32, Allocator, NativeArrayOptions) (at /Users/bokken/build/output/unity/unity/Runtime/Export/NativeArray/NativeArray.cs:58) DynamicBoneBeta:Awake() (at Assets/DynamicBoneBeta.cs:176) UnityEngine.GameObject:SetActive(GameObject, Boolean)
我用Unity2021.3.43f1打开运行,报错:
InvalidOperationException: The previously scheduled job DynamicBoneManager:FinalJob reads from the Unity.Collections.NativeList
1[DynamicBoneBeta+Particle] FinalJob.ParticleInfo. You must call JobHandle.Complete() on the job DynamicBoneManager:FinalJob, before you can deallocate the Unity.Collections.NativeList
1[DynamicBoneBeta+Particle] safely. Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle.CheckDeallocateAndThrow (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle handle) (at <8814d6ed8fb84c9c8b81beb3efe22345>:0) Unity.Collections.LowLevel.Unsafe.DisposeSentinel.Dispose (Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle& safety, Unity.Collections.LowLevel.Unsafe.DisposeSentinel& sentinel) (at /Users/bokken/build/output/unity/unity/Runtime/Export/NativeArray/DisposeSentinel.cs:78) Unity.Collections.NativeList`1[T].Dispose () (at Library/PackageCache/com.unity.collections@1.5.1/Unity.Collections/NativeList.cs:521) DynamicBoneManager.OnDestroy () (at Assets/DynamicBoneManager.cs:484)OnDestory中的释放资源似乎有问题