godot icon indicating copy to clipboard operation
godot copied to clipboard

`await` results in `GDScriptFunctionState` memory leaks

Open MikeSchulze opened this issue 2 years ago • 4 comments
trafficstars

Godot version

v4.0.stable.official [92bee43ad]

System information

Windows 10

Issue description

Using await results in memory leak.

I got a lot of orphan nodes at exit after execution my test coverage (using GdUnit4). The tests uses some stuff around timeouts and await for signals and function results.

I've boiled it down so far, and it looks like a simple "await get_tree().process_frame". already suffices to get orphan nodes,

Leaked instance: GDScriptFunctionState:-9222494076819996251
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).

I found this issue https://github.com/godotengine/godot/issues/57126, but it is already closed.

And also a lot of orphan StringName are found, i guess this is already adressed.

Steps to reproduce

execute the attached scene by

Godot.exe --verbose -d res://Orphans.tscn

XR: Clearing primary interface
XR: Removed interfaceNative mobile
XR: Removed interfaceOpenXR
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:1982)
Leaked instance: GDScriptFunctionState:-9222496825599065104
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).
Orphan StringName: OP_MODULE
....

Minimal reproduction project

orphan_await.zip

MikeSchulze avatar Mar 05 '23 19:03 MikeSchulze

The same in the current master [5dccc940e73d39a1ac4f3d64ccc92373e6609add].

kleonc avatar Mar 05 '23 22:03 kleonc

Hello, what is the current status on the subject? The amount of orphaned objects is smoothly overwhelming ;)

MikeSchulze avatar May 01 '23 09:05 MikeSchulze

what is the current status on the subject?

I can see/tell as much as you do: no one said anything in here, no linked PR / other issues. So I'd guess no one investigated this. I'll put a link at the contributor's chat, maybe someone will get interested.

kleonc avatar May 01 '23 19:05 kleonc

it sill occurs on v4.1.stable.official [970459615]

MikeSchulze avatar Jul 10 '23 08:07 MikeSchulze