Question when terminate immediately after awai signal

Godot Version

4.3

Question

I have found that if the program is terminated immediately after an await signal operation, it can lead to memory leaks and the following errors. What are the significant impacts of these issues? Or can they be ignored?

# await the signal
await get_tree().create_timer(10.0).timeout
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2284)
Leaked instance: SceneTreeTimer:9223372069872338271
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not free.
Orphan StringName: timeout (static: 0, total: 1)
StringName: 1 unclaimed string names at exit.
CrashHandlerException: Program crashed with signal 11

There’s a hint from the object.cpp:

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

Can you show the code around this line? We need to know what exactly happened to reproduce this issue.

1 Like

run a scene only have a node with script only awai signal in _ready method

image

–verbose console message

WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2284)
Leaked instance: SceneTreeTimer:9223372065912915247
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not free.
Orphan StringName: timeout (static: 0, total: 1)
StringName: 1 unclaimed string names at exit.

Still can’t reproduced. Are there any specific procedure needed after running the scene?

i run the scene and then exit game.
need run in godot console

.\Godot_v4.3-stable_win64_console.exe --verbose

i don’t know why,but
it will leak
image

it won’t leak
image

The docs say somewhere that you’re not supposed to use await in the _ready function, but I don’t know if it has to do something with this issue…

i think maybe the refcounted cause leak?
image

if use the Timer instead. Timer won’t leak.
only the signal_name [timeout] orphan.

func _ready() -> void:
	var timer = Timer.new()
	timer.autostart =true
	timer.wait_time = 10.0
	add_child(timer)
	await timer.timeout
	#await get_tree().create_timer(10.0).timeout
	print("hello world")
Orphan StringName: timeout (static: 0, total: 1)
StringName: 1 unclaimed string names at exit.

i think the reason maybe
when await signal, maybe it will create reference to the RefCounted.
when exit game, it only free the scene tree.
but the RefCounted still await the signal.
so, the RefCounted object leak.

2 Likes

Ok reproduced. But I think it’s a Godot bug. There are several issues about this problem on GitHub.

However I think it should be harmless because the game is quitting, the memory leak will be collected with the process.

If so, perhaps using a Timer instead is a better option.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.