Leak Detected on Jobs

I’ve a lot of leaks. Using 4.3.94, but I don’t know from which version they started to appear (they’ve been around for a while).
I’ll post all different ones:

Found 1 leak(s) from callstack:
0x000001a5c88a29e3 (Mono JIT Code) Unity.Collections.Memory/Unmanaged/Array:Resize (void*,long,long,Unity.Collections.AllocatorManager/AllocatorHandle,long,int) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/Memory.cs:79)
0x000001a5c88a28a3 (Mono JIT Code) Unity.Collections.Memory/Unmanaged:Allocate (long,int,Unity.Collections.AllocatorManager/AllocatorHandle) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/Memory.cs:20)
0x000001a5c88a2513 (Mono JIT Code) Unity.Collections.AllocatorManager:TryLegacy (Unity.Collections.AllocatorManager/Block&) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/AllocatorManager.cs:1023)
0x000001a5c88a210b (Mono JIT Code) Unity.Collections.AllocatorManager:Try (Unity.Collections.AllocatorManager/Block&) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/AllocatorManager.cs:1055)
0x000001a5c88a1f9b (Mono JIT Code) Unity.Collections.AllocatorManager/AllocatorHandle:Try (Unity.Collections.AllocatorManager/Block&) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/AllocatorManager.cs:540)
0x000001a5c88a1953 (Mono JIT Code) Unity.Collections.AllocatorManager:AllocateBlock<Unity.Collections.AllocatorManager/AllocatorHandle> (Unity.Collections.AllocatorManager/AllocatorHandle&,int,int,int) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/AllocatorManager.cs:32)
0x000001a5c88a16fb (Mono JIT Code) Unity.Collections.AllocatorManager:Allocate<Unity.Collections.AllocatorManager/AllocatorHandle> (Unity.Collections.AllocatorManager/AllocatorHandle&,int,int,int) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/AllocatorManager.cs:53)
0x000001a5c88ab97b (Mono JIT Code) Unity.Collections.LowLevel.Unsafe.UnsafeList1<int>:ResizeExact<Unity.Collections.AllocatorManager/AllocatorHandle> (Unity.Collections.AllocatorManager/AllocatorHandle&,int) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/UnsafeList.cs:354) 0x000001a5c88ab8b3 (Mono JIT Code) Unity.Collections.LowLevel.Unsafe.UnsafeList1:SetCapacity<Unity.Collections.AllocatorManager/AllocatorHandle> (Unity.Collections.AllocatorManager/AllocatorHandle&,int) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/UnsafeList.cs:390)
0x000001a5c88ab7eb (Mono JIT Code) Unity.Collections.LowLevel.Unsafe.UnsafeList1<int>:SetCapacity (int) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/UnsafeList.cs:399) 0x000001a5c9683683 (Mono JIT Code) Unity.Collections.LowLevel.Unsafe.UnsafeList1:Resize (int,Unity.Collections.NativeArrayOptions) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/UnsafeList.cs:331)
0x000001a5c96834c3 (Mono JIT Code) Unity.Collections.NativeList1<int>:Resize (int,Unity.Collections.NativeArrayOptions) (at ./Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/NativeList.cs:799) 0x000001a5c9682873 (Mono JIT Code) Pathfinding.HierarchicalGraph/JobRecalculateComponents:Grow (Pathfinding.HierarchicalGraph) (at ./Library/PackageCache/com.arongranberg.astar@4.3.94/Core/Pathfinding/HierarchicalGraph.cs:282) 0x000001a5c9682323 (Mono JIT Code) Pathfinding.HierarchicalGraph/JobRecalculateComponents:GetHierarchicalNodeIndex (Pathfinding.HierarchicalGraph) (at ./Library/PackageCache/com.arongranberg.astar@4.3.94/Core/Pathfinding/HierarchicalGraph.cs:297) 0x000001a5c9680f7b (Mono JIT Code) Pathfinding.HierarchicalGraph/JobRecalculateComponents:Execute () (at ./Library/PackageCache/com.arongranberg.astar@4.3.94/Core/Pathfinding/HierarchicalGraph.cs:535) 0x000001a5c967fa1b (Mono JIT Code) Unity.Jobs.IJobExtensions/JobStruct1<Pathfinding.HierarchicalGraph/JobRecalculateComponents>:Execute (Pathfinding.HierarchicalGraph/JobRecalculateComponents&,intptr,intptr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,int)
0x000001a5c967fafa (Mono JIT Code) (wrapper delegate-invoke) Unity.Jobs.IJobExtensions/JobStruct`1/ExecuteJobFunction<Pathfinding.HierarchicalGraph/JobRecalculateComponents>:invoke_void_T

Found 257 leak(s) from callstack:
0x00007ff9dd0a00bc (fba3c7d244586bd1539dd0cee1b7976) Unity.Jobs.IJobExtensions.JobStruct1<Pathfinding.RVO.JobDestinationReached1<Pathfinding.RVO.XYMovementPlane>>.Execute(ref Pathfinding.RVO.JobDestinationReached`1<Pathfinding.RVO.XYMovementPlane> data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) → void_f33d31ae0d43d27135e0ad320d237c4c from UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null (at E:/utenti/willyx/Documents/Unity/Dungeon of Sacrifices/Library/PackageCache/com.unity.burst@1.8.12/.Runtime/unknown/unknown:0)
0x00007ff9dd09fa6d (fba3c7d244586bd1539dd0cee1b7976) 83b69da799ecd4caee3f295ea8a386eb
0x00007ff61f3189a2 (Unity) ExecuteJob
0x00007ff61f319d8f (Unity) ForwardJobToManaged
0x00007ff61f315c5a (Unity) ujob_execute_job
0x00007ff61f31521d (Unity) lane_guts
0x00007ff61f317c24 (Unity) worker_thread_routine
0x00007ff61f5439f6 (Unity) Thread::RunThreadWrapper
0x00007ffa2ebe257d (KERNEL32) BaseThreadInitThunk
0x00007ffa2f28aa58 (ntdll) RtlUserThreadStart

Found 1 leak(s) from callstack:
0x00007ff9d5077002 (cadcf2090e142902b6f3b87df66b7d0) Unity.Collections.LowLevel.Unsafe.UnsafeList1<Pathfinding.RVO.UnmanagedObstacle>.ResizeExact<Unity.Collections.AllocatorManager.AllocatorHandle> (at E:/utenti/willyx/Documents/Unity/Dungeon of Sacrifices/Library/PackageCache/com.unity.burst@1.8.12/.Runtime/Library/PackageCache/com.unity.collections@2.1.4/Unity.Collections/UnsafeList.cs:354) 0x00007ff9d5076dd5 (cadcf2090e142902b6f3b87df66b7d0) Unity.Jobs.IJobExtensions.JobStruct1<Pathfinding.NavmeshEdges.JobResizeObstacles>.Execute(ref Pathfinding.NavmeshEdges.JobResizeObstacles data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) → void_1a17c9416545ae7079718413b8a5101d from UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null (at E:/utenti/willyx/Documents/Unity/Dungeon of Sacrifices/Library/PackageCache/com.unity.burst@1.8.12/.Runtime/unknown/unknown:0)
0x00007ff9d50765bd (cadcf2090e142902b6f3b87df66b7d0) 3bd77803aec02ab8933cdb293fb311ce
0x00007ff61f3189a2 (Unity) ExecuteJob
0x00007ff61f319d8f (Unity) ForwardJobToManaged
0x00007ff61f315c5a (Unity) ujob_execute_job
0x00007ff61f31521d (Unity) lane_guts
0x00007ff61f317c24 (Unity) worker_thread_routine
0x00007ff61f5439f6 (Unity) Thread::RunThreadWrapper
0x00007ffa2ebe257d (KERNEL32) BaseThreadInitThunk
0x00007ffa2f28aa58 (ntdll) RtlUserThreadStart

Hi

Can you consistently replicate this leak?

I get the Found 257 leak(s) from callstack: only when using RVO Simulator (obviously).
Do you mean if I can get you a minimal code with these leaks?

Thanks!
I’ve managed to replicate this now. I will include a fix in the next update.

1 Like

Sorry, still there with 4.3.95 :frowning:

Found 257 leak(s) from callstack:
0x00007ff9e4ac065c (405a9f50075e26fb9930c19fe5b6b1a) Unity.Jobs.IJobExtensions.JobStruct1<Pathfinding.RVO.JobDestinationReached1<Pathfinding.RVO.XYMovementPlane>>.Execute(ref Pathfinding.RVO.JobDestinationReached`1<Pathfinding.RVO.XYMovementPlane> data, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) → void_f33d31ae0d43d27135e0ad320d237c4c from UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null (at E:/utenti/willyx/Documents/Unity/Dungeon of Sacrifices/Library/PackageCache/com.unity.burst@1.8.12/.Runtime/unknown/unknown:0)
0x00007ff9e4abffcd (405a9f50075e26fb9930c19fe5b6b1a) 83b69da799ecd4caee3f295ea8a386eb
0x00007ff76a2f89a2 (Unity) ExecuteJob
0x00007ff76a2f9d8f (Unity) ForwardJobToManaged
0x00007ff76a2f5c5a (Unity) ujob_execute_job
0x00007ff76a2f521d (Unity) lane_guts
0x00007ff76a2f7c24 (Unity) worker_thread_routine
0x00007ff76a5239f6 (Unity) Thread::RunThreadWrapper
0x00007ffa2ebe257d (KERNEL32) BaseThreadInitThunk
0x00007ffa2f28aa58 (ntdll) RtlUserThreadStart

Weird… If you have a test project in which you can replicate this, I would be very interested.

Here a prj.
I think that the problem is the URP stuff
the leak happen at the second+ run of SampleScene

https://willyx.it/testURP2d.zip

Ok, I’m 100% sure Unity’s NativeQueue has a bug. I can replicate this leak, but only when burst is enabled. And I verify that I am allocating a queue exactly the same number of times as I am disposing it. So something’s off.

I’ll switch it out to my own queue implementation for the next release (which is probably faster too).

1 Like