-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Potential Memory Leak because of move_and_slide()
against Each Collidable Bodies
#84036
Comments
move_and_slide()
against Each Collidable Bodiesmove_and_slide()
against Each Collidable Bodies
move_and_slide()
against Each Collidable Bodiesmove_and_slide()
against Each Collidable Bodies
Please provide a reproduction project. The exact setup you're using is necessary to reproduce the issue. It sounds like you're using GDExtension which isn't mentioned at all in the steps to reproduce, and is far from trivial to setup. |
I can't see the video, nothing is shown even if I press the play button. |
I attached it now |
Thanks, I can reproduce the issue that the Object count seems to keep increasing. |
@Lazy-Rabbit-2001 Wrong issue linked?
The increasing Object count seems to be godot/scene/2d/physics_body_2d.cpp Line 1120 in ba79e53
godot/servers/physics_2d/godot_body_2d.cpp Lines 734 to 740 in ba79e53
Not sure if that's a bug, such created GodotPhysicsDirectBodyState2D is cleared in the GodotBody2D's destructor: godot/servers/physics_2d/godot_body_2d.cpp Lines 750 to 757 in ba79e53
|
sorry, the link does be wrong and I fixed it just now |
I mentioned an issue that the direct state can get deleted only when the body is removed from the memory, but what if the body is running? |
Seems that the pr #90668 may fix this issue, as I saw that the pr switched pointer to ObjectID that may seem to solve the problem of making Once the pr gets merged and another test for the bug, which will be conducted in the version where the feature of that pr gets implemented, does not fail freeing the |
Godot version
4.2 beta 3 ~ 4.3 dev 6
System information
Windows 11, GLES3
Issue description
This is an extended issue from #57073 opened by @BeayemX.
At first I didn't realize that
get_slide_collision()
could be a memory leaker until I found something abnormal yesterday when I test a GDExtension, in which I used this call to get the last slide collision and emit some signals with this object, but when the debug began and I tested it for seconds, I found the "Object" amount in profiler was increasing. And then I searched around the issues tab and finally found that issue at the beginning of this report.But things is always coming with dark clouds. When I returned to remove this call, a weird thing happened: the amount of object was still increasing after the removal of using the method! To research more, I started figuring out what happened with this phenomenon and eventually found this dark cloud:
I opened a new project with only a
CharacterBody2D
using template moving code, and aTileMaps
with tiles. Every time themove_and_slide()
is called and the collision between the body calling the method and another one that the body haven't collided with (if it's aTileMap
, each piece of tile is considered as an individual collision body), the amount of collision increased.Could this be a high-priority problem?
Yes, and the reason lays on two aspects:
If this is true, then this is a disastrous potential glitch with the process of
RefCounted
.Why should this be a independent and new issue rather than response in that issue?
This has been not only an issue related to
get_slide_collision()
, but even one tomove_and_slide()
or even toRefCounted
.Steps to reproduce
Make a
CharacterBody2D
move withmove_and_slide()
and collide with any collision bodies.Minimal reproduction project
Issue.zip
(No GDExtensions)
The text was updated successfully, but these errors were encountered: