Leak Detected : Persistent allocates 3 individual allocations

  • A* version: [5.2.3]
  • Unity version: [2022.3.21f1]
  • Burst version: [1.8.18]

Updated to 5.2.3 from 4.2.19 for Recast 2D. Immediately noticed the leak.
Leaks happen when a scene with a AstarPath component in it is played.
Leaks even happen in a newly created project after importing the package and creating a Gameobject with AstarPath component.
Leaks happen both in Unity 2022.3.21 and 2022.3.49.

Here’s the log:

Leak Detected : Persistent allocates 3 individual allocations.

Found 2 leak(s) from callstack:
0x0000020eaf36a8a3 (Mono JIT Code) Pathfinding.BinaryHeap:.ctor (int) (at ./Packages/com.arongranberg.astar/Core/Collections/BinaryHeap.cs:90)
0x0000020eaf36a683 (Mono JIT Code) Pathfinding.PathHandler:.ctor (Pathfinding.GlobalNodeStorage,int,int) (at ./Packages/com.arongranberg.astar/Core/Pathfinding/PathHandler.cs:191)
0x0000020eaf36a40b (Mono JIT Code) Pathfinding.PathProcessor:SetThreadCount (int,bool) (at ./Packages/com.arongranberg.astar/Core/Pathfinding/PathProcessor.cs:99)
0x0000020eaf369b8b (Mono JIT Code) AstarPath:InitializePathProcessor () (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1201)
0x0000020eadaac50b (Mono JIT Code) AstarPath:OnEnable () (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1298)
0x0000020f9eb61198 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffe67dc4bfe (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ffe67cfd254 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
0x00007ffe67cfd3cc (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
0x00007ff73b1f03a4 (Unity) scripting_method_invoke
0x00007ff73b1ce114 (Unity) ScriptingInvocation::Invoke
0x00007ff73b1b5904 (Unity) MonoBehaviour::CallMethodIfAvailable
0x00007ff73b1b3d66 (Unity) MonoBehaviour::AddToManager
0x00007ff73b1b497a (Unity) MonoBehaviour::AwakeFromLoad
0x00007ff73b2b2c9d (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
0x00007ff73b2b3c71 (Unity) AwakeFromLoadQueue::PersistentManagerSingleQueueAwakeFromLoad
0x00007ff73b2b38e0 (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad_NoChecks
0x00007ff73aeaf9d5 (Unity) LoadSceneOperation::CompleteAwakeSequence
0x00007ff73aeb0550 (Unity) LoadSceneOperation::CompletePreloadManagerLoadSceneEditor

Found 1 leak(s) from callstack:
0x0000020eaf36a8a3 (Mono JIT Code) Pathfinding.BinaryHeap:.ctor (int) (at ./Packages/com.arongranberg.astar/Core/Collections/BinaryHeap.cs:90)
0x0000020eaf36a683 (Mono JIT Code) Pathfinding.PathHandler:.ctor (Pathfinding.GlobalNodeStorage,int,int) (at ./Packages/com.arongranberg.astar/Core/Pathfinding/PathHandler.cs:191)
0x0000020eaf36a40b (Mono JIT Code) Pathfinding.PathProcessor:SetThreadCount (int,bool) (at ./Packages/com.arongranberg.astar/Core/Pathfinding/PathProcessor.cs:99)
0x0000020eaf369b8b (Mono JIT Code) AstarPath:InitializePathProcessor () (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1201)
0x0000020eadaac50b (Mono JIT Code) AstarPath:OnEnable () (at ./Packages/com.arongranberg.astar/Core/AstarPath.cs:1298)
0x0000020f9eb61198 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffe67dc4bfe (mono-2.0-bdwgc) mono_jit_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/mini/mini-runtime.c:3445)
0x00007ffe67cfd254 (mono-2.0-bdwgc) do_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3068)
0x00007ffe67cfd3cc (mono-2.0-bdwgc) mono_runtime_invoke (at C:/build/output/Unity-Technologies/mono/mono/metadata/object.c:3115)
0x00007ff73b1f03a4 (Unity) scripting_method_invoke
0x00007ff73b1ce114 (Unity) ScriptingInvocation::Invoke
0x00007ff73b1b5904 (Unity) MonoBehaviour::CallMethodIfAvailable
0x00007ff73b1b3d66 (Unity) MonoBehaviour::AddToManager
0x00007ff73b27038a (Unity) SerializableManagedRefsUtilities::AwakeInstancesAfterBackupRestoration
0x00007ff73b1b8c0f (Unity) MonoManager::FinalizeReload
0x00007ff73c5b03da (Unity) ScriptingInitializer::FinalizeReload
0x00007ff73c625504 (Unity) ImportOutOfDateAssets
0x00007ff73c62fabc (Unity) RefreshInternalV2
0x00007ff73c6373fc (Unity) StopAssetImportingV2Internal

Hi

I have not been able to replicate this, I’m afraid.

  • I used 2022.3.12
  • I enabled leak tracing
  • Created a new empty scene
  • Added an empty GameObject
  • Attached an AstarPath component
  • I entered and exited play mode a few times.

This is so weird.
Please watch this video, I created a new scene in a new project to replicate the problem.

Do you think you could try to upgrade burst, collections and (if you use it) the entities package to the latest version supported on your version of unity, and then try again?

I cannot replicate this using Unity 2021.3 and burst 1.8.7 either.

Turned out it was Collections that is causing the problem.
Updated Collections to 2.5.1 and the game is running perfectly!

1 Like