The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

0 votes

Hi all,

Sorry for the basic question. I have some data classes that inherit from Object, are created at the beginning of the game and never destroyed.

The documentation says that should be called for Objects to avoid memory leaks. Am I correct in believing this isn't necessary if the Object is never actually removed?

Basically, does the application automatically delete everything when it's closed? Or do I need to call somewhere (such as _on_exit_tree) to ensure the application doesn't leave anything around?


Godot version 4.0.beta4.official
in Engine by (35 points)

Very good Question dude, hope you get it answered.
Godot boasts about its garbage collection and recommends using Reference (Think its called something else in Godot4) instead.

For me personally can't get the C way of having to do everything yourself out of my system and always do

func foo():
    var array = Array()
    # use array here
    array = null   

1 Answer

+2 votes
Best answer

All objects will be "disposed" when the program is closed. The OS will make sure of this.

by (1,055 points)
selected by

To slightly expand on this, operating systems will reclaim all resources when a program exits. Any existing Godot objects that haven't been properly disposed will just cease to exist upon program exit, just like in any other language.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.