Memory Leak with Grid Graphs

  • A* version: [5.3.7]
  • Unity version: [6000.1.2f1]

I’m getting a memory leak in editor mode, unsure what’s causing it. Here is the first error:

Leak Detected : Persistent allocates 7 individual allocations.

Followed by 7 individual messages. I’ll just include the first one -

Found 1 leak(s) from callstack:
0x000001acb13fed4b (Mono JIT Code) Unity.Collections.NativeArray1<bool>:Allocate (int,Unity.Collections.Allocator,Unity.Collections.NativeArray1&)
0x000001acb13fec33 (Mono JIT Code) Unity.Collections.NativeArray1<bool>:.ctor (int,Unity.Collections.Allocator,Unity.Collections.NativeArrayOptions) 0x000001acb13fea83 (Mono JIT Code) Pathfinding.Jobs.JobDependencyTracker:NewNativeArray<bool> (int,Unity.Collections.Allocator,Unity.Collections.NativeArrayOptions) (at ./Packages/com.arongranberg.astar/Utilities/JobDependencyTracker.cs:308) 0x000001acb13f71d3 (Mono JIT Code) Pathfinding.Graphs.Grid.GridGraphNodeData:AllocateBuffers (Pathfinding.Jobs.JobDependencyTracker) (at ./Packages/com.arongranberg.astar/Graphs/Grid/GridGraphScanData.cs:139) 0x000001acb13f252b (Mono JIT Code) Pathfinding.GridGraph/GridGraphUpdatePromise/<Prepare>d__22:MoveNext () (at ./Packages/com.arongranberg.astar/Graphs/GridGraph.cs:1875) 0x000001acb13f07b6 (Mono JIT Code) Pathfinding.GraphUpdateProcessor:PrepareGraphUpdatePromises (System.Collections.Generic.List1<System.ValueTuple2<Pathfinding.IGraphUpdatePromise, System.Collections.Generic.IEnumerator1<Unity.Jobs.JobHandle>>>,Pathfinding.Jobs.TimeSlice) (at ./Packages/com.arongranberg.astar/Core/Pathfinding/GraphUpdateProcessor.cs:238)
0x000001acb13d7fe3 (Mono JIT Code) AstarPath/d__129:MoveNext () (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1787)
0x000001acb13d5659 (Mono JIT Code) AstarPath:Scan (Pathfinding.NavGraph) (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1569)
0x000001abc081c8ab (Mono JIT Code) AstarPath:OnEnable () (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1307)
0x000001ac6ebc15e8 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffc6cd368de (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ffc6cc78404 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
0x00007ffc6cc784f0 (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
0x00007ffc6449af04 (Unity) scripting_method_invoke
0x00007ffc64472e13 (Unity) ScriptingInvocation::Invoke
0x00007ffc6445e234 (Unity) MonoBehaviour::CallMethodIfAvailable
0x00007ffc6445ca7a (Unity) MonoBehaviour::AddToManager
0x00007ffc6445d393 (Unity) MonoBehaviour::AwakeFromLoad
0x00007ffc64557ce9 (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake

Are you sure there are no other errors or warnings before that?
Btw. Make sure your collections, burst and mathematics packages are using the latest versions.

Hey Aron, no other errors/warnings outside of the leak and collections/burst/mathematics packages are up to date.