0 votes

I have bit of confusion what is the right way to handle instantiated node removal from array so no memory leaks or to much garbage collection would occur.

# this feels wrong??
my_node_array[5] = null 

# how about this, to temp variable or straight from array?
my_node = my_node_array[5]

# 1. way ?
get_parent().remove_child(my_node)
# 2. way or both??
my_node.queue_free()

# finally.. needed or not??
my_node_array[5] = null

#check to get state of array element ????
if my_node_array[5].is_instance_valid():  vs. if my_node_array[5] == null:
in Engine by (38 points)

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.

Categories