- Edited
On running the profiler I can see that the Objects
count in Monitors keeps increasing due to a specific function call. Is it possible to check which specific class objects are increasing in count here?
Might be unrelated but I'll describe the scenario if it helps:
- I'm working on implementing an Astar pathfinding library for 2D platformers. I have a tilemap for the level layout. There can be multiple agents that will traverse this tilemap
- I'm scanning the tilemap to generate a 2D array (using a manually created 2D array class). This will be common for the multiple agents using the pathfinding logic. Common because it will store the coordinates and metadata about the tile which might be needed for the pathfinding logic later.
- Each agent will have it's own Pathfinding class object. Each agent will have it's own Astar nodes in this pathfinding object. This way if a tile is common for two agents, the Astar node F cost can be different for both of them on the same map location.
- The pathfinding Astar nodes are being stored in an Array2D. I have added
extends RefCounted
at the top of the Astar node class, assuming Godot will remove these objects when these are no longer stored in the Array2D. I also tried addingqueue_free
when changing any Astar node value in the Array2D but the memory leak is still there. - The pathfinding function is being called by the agents in
_process
. There will be a parameter to throttle this for performance but I'm testing it out without that first.