Overwriting existing paths best practice

So I have a path variable, its all valid and dandy, but then I decide to just generate a new path and assign it to the same variable. I assume the old one will be GCed at some point but from my understanding it will still be in the path cache internal to A* so is there a way to tell the path its finished and it will be GCed at some point?

Or should I just not bother and overwrite regardless?


The path is not stored in any internal cache, I have made sure of that. So if you calculate a new path, you can just forget about the old one, it will be GCed properly.

If you think the GC is doing a bad job and this is creating a lot of garbage in your game, you can use path pooling to recycle path instances. See http://arongranberg.com/astar/docs/pooling.php

Yeah have read about pooling, do not need that functionality yet so will just ignore them and let them fade into oblivion.

Thanks for clearing it up.