Godot Version
v4.3.stable.mono.official [77dcf97d8]
Question
Occasionally when I close my game, I get the following exception in my IDE:
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
at: cleanup (core/object/object.cpp:2284)
I wanted to track down the issue so I started digging a bit. After running my game with the verbose param, I got the following message at the end:
Leaked instance: Node:63535318754 - Node name:
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: _enter_tree (static: 0, total: 1)
Orphan StringName: _unhandled_input (static: 0, total: 1)
Orphan StringName: _ready (static: 0, total: 1)
Orphan StringName: _exit_tree (static: 0, total: 1)
Orphan StringName: _input (static: 0, total: 1)
Orphan StringName: _shortcut_input (static: 0, total: 1)
Orphan StringName: _process (static: 0, total: 1)
Orphan StringName: _unhandled_key_input (static: 0, total: 1)
Orphan StringName: _get_configuration_warnings (static: 0, total: 1)
Orphan StringName: _physics_process (static: 0, total: 1)
StringName: 10 unclaimed string names at exit.
However, at this point, I got completely stuck. As you can see, the output gave me no useful node names at all, and I have no idea how to find the node like this.
I assumed the number it gave me was a node ID, so I listed ALL the nodes (recursive) while my game was running before closing it, but the ID did not match a single node that I listed using the following code:
foreach (Node node in NodeHelpers.GetAllChildrenOfType<Node>(GetTree().Root))
{
Log.Debug("Node name: {name}, with ID: {id}", node.Name, node.GetInstanceId());
}
Code for GetAllChildrenOfType:
public static IEnumerable<T> GetAllChildrenOfType<T>(Node nodeToLookThrough) where T : Node
{
List<T> nodes = new();
foreach (Node child in nodeToLookThrough.GetChildren())
{
if (child is T node)
{
nodes.Add(node);
}
if (child.GetChildren().Count > 0)
{
nodes.AddRange(GetAllChildrenOfType<T>(child));
}
}
return nodes;
}
If you know what might cause this please let me know, because I’d really like to do something about it, it feels wrong to see exceptions almost EVERY single time I close my game.