Large amount of graph node array and list

  • A* version: [5.3.8]
  • Unity version: [2022.3.42f1]
    Hello,I am currently analyzing memory of my game by memory profiler to do some optimization.And I found that as the game progress,it will generate thousands of GraphNode and List.Is it normal?


I marked the wrong graph node list in the second picture,it should be on the third line under the first green box (11,234 items)

Hi

Every node in a navmesh/recast graph will allocate one GraphNode[] per node to hold its connections. So it is expected to find a lot of them. The lists are likely in a pool, to be able to be reused later.

If you want to minimize memory usage after the graphs have been scanned, you can try:

ListPool<Pathfinding.GraphNode>.Clear();

But this will increase GC allocations if graph node lists are needed again (e.g. during graph updates).

Thanks for reply!It is useful!They have restored the normal quantity :smiley: