You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When reusing the returned Dictionary from PhysicsDirectSpaceState3D::intersect_ray() for repeated intersect_ray calls there is a notable memory leak that does not get cleaned up until restarting the editor or project. This leak can occur both in the editor and in the export project.
I would expect this to work similar to other Variant types and unreference the reserved memory when reassigned.
leak.mp4
Steps to reproduce
I have included a MRP. To reproduce in the MRP:
open the raycast_leak_test.tscn scene. Open task manager to monitor the godot memory usage.
Add a RaycastLeaker node to the scene. You should be able to observe the memory usage of the godot process climbing.
Remove the RaycastLeaker node. You should see the climbing stop, but the memory usage does not return to its original value.
I have also included a version of the node that does not leak by simply declaring a new dictionary for every intersect_ray call.
Add a RaycastNoLeak node to the scene. You should see the memory usage of the engine remain stable.
The leak can also be reproduces by creating your own node with the following physics_process function, and setting up the scene so that the repeated raycasts hit a collision object.
Godot version
v4.7.stable.official (5b4e0cb0f)
godot-cpp version
9c8aeff
System information
Windows 11 (build 26200) - Multi-window, 2 monitors - Direct3D 12 (Forward+) - dedicated NVIDIA GeForce RTX 4070 SUPER (NVIDIA; 32.0.16.1047) - 12th Gen Intel(R) Core(TM) i7-12700K (20 threads) - 31.77 GiB memory - WASAPI (48000 Hz, Stereo/mono)
Issue description
When reusing the returned Dictionary from PhysicsDirectSpaceState3D::intersect_ray() for repeated intersect_ray calls there is a notable memory leak that does not get cleaned up until restarting the editor or project. This leak can occur both in the editor and in the export project.
I would expect this to work similar to other Variant types and unreference the reserved memory when reassigned.
leak.mp4
Steps to reproduce
I have included a MRP. To reproduce in the MRP:
RaycastLeakernode to the scene. You should be able to observe the memory usage of the godot process climbing.RaycastLeakernode. You should see the climbing stop, but the memory usage does not return to its original value.I have also included a version of the node that does not leak by simply declaring a new dictionary for every intersect_ray call.
RaycastNoLeaknode to the scene. You should see the memory usage of the engine remain stable.The leak can also be reproduces by creating your own node with the following physics_process function, and setting up the scene so that the repeated raycasts hit a collision object.
Minimal reproduction project
leaky_project.zip