Reducing memory for large 2d map cache


The screenshot is from a memory profiler using a Windows server build. Im using a grid graph with cached startup with 900k nodes. I read that grid graph does take up a lot more memory especially with this size, but It adds a LOT of extra memory, about 700mb+, nearly double the server size without it

Im wondering if all those pathNodes are necessary to hold in memory? I assume the pathNodes are constructed using the single GridNodes array and can be reconstructed when seeking new paths anyway, so there is no reason to keep them around. And of course, when the path is done to release those pathNodes from memory as well. Or am i mistaken about where all this extra memory being held hostage is coming from in the package?

How can I remove the pathNodes, just keep the GridNode[] and use those when seeking paths? Is it possible?

Hi

The path nodes are per-thread data. So you can reduce the memory usage by reducing the number of pathfinding threads. Take a look at A* Inspector → Settings → Pathfinding → Threads.

For performance and to avoid GC pressure, it is much better to pre-allocate all the data needed for pathfinding, instead of dynamically allocating the data during the search.

1 Like