Just wondering, is it possible to clear the Path Pool? Having some leaks and I feel Path Pool may be involved somewhere, so if I could clear the pool it’d help verify if that is the issue (Path Pool still seems to be used even if I disable pool).
If you disable the pooling using the compiler directive the path pool will just return new instances every time and it will ignore any requests to pool objects.
Yeah I was trying that but it didn’t seem to apply. I hadn’t noticed the errors though when I clicked “Apply” button in Optimization settings. So I had to make a few changes to the code so it’d work.
In OptimizationHandler.cs, I had to add the following after line 37 due to errors (seems Unity has made changes to build targets):
Thanks for the heads up. My automated testing script didn’t catch that one (fixed that now, it never tested with ASTAR_NO_POOLING without ASTAR_OPTIMIZE_POOLING).
I’m not sure why you have to add those lines to the OptimizationHandler however. What errors does Unity output?
Ah. Yeah it’s annoying that there is no way to detect which build targets are deprecated using a script.
I have just uploaded 3.8.8.1 which prevents the script from trying to set those build targets after the version of Unity when they were deprecated. It got rid of that warning for me at least, not sure why it wasn’t removed for you.
My understanding is that the warnings are there because previously they were set for the now deprecated build targets, and now that I’ve changed the value it’s not updating it for the deprecated build targets as it can’t.
Anyway, glad you were able to sort it out quickly, thanks!
Just back to the original issue, setting the system not to pool paths solved the memory leaks I was having. The problem is that some of our agent objects are remaining in memory after a scene change because they are been referenced by a path in the pool.
Maybe I’m barking up the wrong tree, but the memory profiler shows that the PathPool is keeping the reference alive.
OnPathDelegate has a reference to the Seeker.
In the agent’s onDestroy function, I try to ensure the seeker is cleared but it doesn’t appear to be working.
_seeker.ReleaseClaimedPath();
_seeker.pathCallback = null;
_seeker = null;
The memory leak isn’t happening for all agents, so I’m guessing that it only happens if an agent was in the process of requesting a path when the scene changed. Can you see anything that I am doing incorrectly?
Cool, I’ll check that out and report back, thanks!
It’s the memory profiler one of the Unity devs started working on with the aim to add it to Unity itself. Unfortunately nothing has come of it, but you can still grab it here. I think you have to make a few changes to get it working with the latest unity.
It’s very work-in-progress with a lot of rough edges, but I find it very useful (wouldn’t have noticed this issue among others without it).