Skip to content

Leak fixes #143

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

Merged
merged 4 commits into from
Jul 17, 2024
Merged

Leak fixes #143

merged 4 commits into from
Jul 17, 2024

Conversation

dbnicholson
Copy link
Member

Some memory leak fixes I found looking at the Godot stdout. After this I get no more warnings about leaked objects in the tests or with minimal usage.

This way the objects are automatically freed when all references are
dropped. Prior to this, running the tests warned about leaked objects:

WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2209)
ERROR: Resources still in use at exit (run with --verbose for details).
   at: clear (core/io/resource.cpp:492)
When exiting the tree, the main panel is freed and should no longer be
updated. This avoids the following error when shutting down:

SCRIPT ERROR: Invalid call. Nonexistent function 'switch_block_code_node' in base 'Nil'.
          at: BlockCodePlugin._refresh_block_code_node (res://addons/block_code/block_code_plugin.gd:160)
In e0a4208, the method name was changed.
Handling the inspector plugin as a static variable of the BlockCode
class means it can never be removed from inspector since we never know
when all BlockCode instances have been destroyed. That means it had to
be leaked as shown in the verbose Godot output:

WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2209)
Leaked instance: EditorPlugin:1833129019089 - Node name:

Instead, add it once from the plugin entry point. That means it can also
be removed when the plugin exits rather than being leaked. This follows
the pattern documented in the Inspector Plugin tutorial[1].

1. https://docs.godotengine.org/en/stable/tutorials/plugins/editor/inspector_plugins.html.
@dylanmccall dylanmccall merged commit fc1155d into main Jul 17, 2024
2 checks passed
@dylanmccall dylanmccall deleted the leak-fixes branch July 17, 2024 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants