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
dctewi
September 1, 2024, 3:33pm
2
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.
WARN_PRINT("ObjectDB instances leaked at exit (run with --verbose for details).");
if (OS::get_singleton()->is_stdout_verbose()) {
// Ensure calling the native classes because if a leaked instance has a script
// that overrides any of those methods, it'd not be OK to call them at this point,
// now the scripting languages have already been terminated.
MethodBind *node_get_path = ClassDB::get_method("Node", "get_path");
MethodBind *resource_get_path = ClassDB::get_method("Resource", "get_path");
Callable::CallError call_error;
for (uint32_t i = 0, count = slot_count; i < slot_max && count != 0; i++) {
if (object_slots[i].validator) {
Object *obj = object_slots[i].object;
String extra_info;
if (obj->is_class("Node")) {
extra_info = " - Node path: " + String(node_get_path->call(obj, nullptr, 0, call_error));
}
if (obj->is_class("Resource")) {
extra_info = " - Resource path: " + String(resource_get_path->call(obj, nullptr, 0, call_error));
}
This file has been truncated. show original
1 Like
run a scene only have a node with script only awai signal in _ready method
–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.
dctewi
September 1, 2024, 3:59pm
4
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
it won’t leak
Monday
September 1, 2024, 4:14pm
7
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?
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
dctewi
September 1, 2024, 4:39pm
10
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.
opened 05:30PM - 19 Jul 23 UTC
bug
topic:gdscript
### Godot version
4.1.1.stable
### System information
Ubuntu 22.04
### Issue… description
If a timer is awaited when `get_tree().quit()` is called, then it is not freed.
```
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
at: cleanup (core/object/object.cpp:2047)
Leaked instance: SceneTreeTimer:-9222497925110692716
```
### Steps to reproduce
* create a scene `main.tscn` with this as the script for the root node:
```
extends Node
func _ready():
async_stuff()
get_tree().quit()
func async_stuff():
await get_tree().create_timer(1.0).timeout
```
* Launch the scene `godot main.tscn --verbose`
* Output should warn about the leak:
```
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
at: cleanup (core/object/object.cpp:2047)
Leaked instance: SceneTreeTimer:-9222495726087437163
```
### Minimal reproduction project
[await_timer_leaked.zip](https://github.com/godotengine/godot/files/12098518/await_timer_leaked.zip)
opened 09:35PM - 13 Nov 23 UTC
bug
topic:core
### Godot version
4.1.3 Stable
### System information
Linux Mint 21.1 C… innamon
### Issue description
If you try to queue_free() a node/scene before an ``await.get_tree().create_timer().timeout`` has completed an object will persist and cause a memory leak.
### Steps to reproduce
Play the main scene and open the Debugger > Monitors tab. Watch as the quantity of Objects continuously go up.
### Minimal reproduction project
[TestProject.zip](https://github.com/godotengine/godot/files/13342185/TestProject.zip)
1 Like
system
Closed
October 1, 2024, 4:39pm
11
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.