ABPath.Construct GC alloc

I’m using ABPath.Construct to calculate if a position is valid (e.g. is it possible for AI navigate to said position). I’m simply doing this:

_aBPath = ABPath.Construct(p1, p2, OnPathComplete);
AstarPath.StartPath(_aBPath);

But I noticed in the profiler that AbPath.Construct always creates a new path in the pool, and never seems to retrieve one. This allocates around 0.6KB of memory every single time. Since I’m doing this quite often at certain points in the game, that’s a massive amount of overhead (especially on Switch / Xbox One).

I feel like I’m missing something, but I can’t find anything useful in the docs about this specifically.

Hi

You can take a look at Pooling - A* Pathfinding Project

You may also be interested in PathUtilities - A* Pathfinding Project

1 Like

Thanks for the super quick response! The pooling was indeed the one I was messing up (and now that it’s implemented properly it’s a lot faster), but IsPathAvailable was the actual answer and is a LOT faster for my use case.

Thanks!

1 Like