Skip to content
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

Implement memory profiling and debugging in GDScript #8143

Open
elinfame opened this issue Oct 16, 2023 · 2 comments
Open

Implement memory profiling and debugging in GDScript #8143

elinfame opened this issue Oct 16, 2023 · 2 comments

Comments

@elinfame
Copy link

Describe the project you are working on

A multiplayer strategy game for the web and desktop.

Describe the problem or limitation you are having in your project

I am subclassing Objects and References for my own custom types, but cannot be sure that I am properly freeing them in all cases. There is currently no way to debug memory issues or profile memory at the GDScript level (e.g. leaks, allocations, zombies). System tools on the target platforms do not have visibility into GDScript objects and require a different tool per platform.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

A tool similar to Xcode Instrument's Leaks/Allocations/Zombies, or browser inspectors' Memory tab, which lets you observe the same. This would let me verify that during a given (manual) test run, objects are being freed appropriately, when I expect them to be, and drill into ones that aren't.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

See https://developer.chrome.com/blog/memory-inspector/ and and here for what this might look like.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not that I'm aware of.

Is there a reason why this should be core and not an add-on in the asset library?

I'm not sure but I imagine it requires a deep integration with the language / VM implementation.

@Calinou Calinou changed the title GDScript Memory Profiling and Debugging Implement memory profiling and debugging in GDScript Oct 16, 2023
@ghost
Copy link

ghost commented Oct 18, 2023

I can't speak to the web side of this issue, but I recently resolved a memory leak thanks to a warning by GUT complaining about orphaned nodes. If you start Godot with --verbose, that should give you more information about orphaned nodes in the output. Node.print_orphan_nodes() may also be of help. This is not a full profiler, but it may help with memory issues.

@Calinou
Copy link
Member

Calinou commented Oct 18, 2023

See the memory allocation monitor that was mentioned in godotengine/godot#62291 (comment). It's implemented in the linked Godot 3.x fork but needs a port to Godot 4 before it can be submitted as a pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants