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.

godotengine.org | Twitter

+1 vote

Like, I have a script that makes an image and assigns it to a local variable in a function. But after I save the image to a file, how do I get rid of it, since I don't need it anymore? Will it just disappear after the function is over?

Edit: Why the downvote? Is my question really that stupid?

in Engine by (8,550 points)
edited by

1 Answer

+3 votes
Best answer

Hi,
your question is not that stupid.

Resources are reference counted. That means if you dont hold any reference anymore they will be freed.
Holding a reference is assigning it to a variable. So if you delete anything pointing to it, its gone.

Reference
Inherits: Object

Base class for anything that keeps a reference count. Resource and many other helper objects inherit this. References keep an internal reference counter so they are only released when no longer in use.

https://docs.godotengine.org/en/3.0/classes/class_reference.html

by (4,088 points)
selected by

Okay, thanks for explaining! I really appreciate it!

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.