- Edited
DaveTheCoder LOL Almost everything it "said" is not true.
DaveTheCoder LOL Almost everything it "said" is not true.
A node is not memory managed in any way except for deletion when its parent is deleted. You can easily cause memory leaks with nodes. Here's a quick example to try:
extends Node
func _process(delta):
for i in 100:
Node.new()
And here's the result:
I could try this myself to get the answer, but what happens if you create a lot of detached nodes like that, and then stop creating them? Will they persist?
DaveTheCoder Why would engine care to hunt them down only when you stop creating them? Of course they will persist.
DaveTheCoder There you go:
extends Node
var itotal = 0
func _process(delta):
if itotal < 1000000:
for i in 1000:
Node.new()
itotal += 1000
xyz Almost everything it "said" is not true.
It was paraphrasing the documentation. Maybe that's the problem.
Anyway to answer the OP directly @Sabir - queue_free()
will purge the node and all of its children from memory as soon as the current frame processing is finished. free()
will do it immediately. In fact queue_free()
is just a deferred call to free()
. And that call will vanish the object from ram 100% guaranteed. After that, all references to the node still held in your code will become invalid and using them will throw an exception.
If you think something is not getting deleted while it should, use Godot's profiler to check if there are indeed some leaks. But you can rest assured that any leaks you may have are not caused by queue_free()
somehow refusing to delete the nodes.
xyz DaveTheCoder LOL
Almost everything it "said" is not true.
Never forget that a whole new generation of developers is getting raised by ChatGPT and will use it every opportunity they get which isn't a scary prospect at all.
Toxe I tend to rant about it from time to time but I get a lot of backlash, typically from people who have no clue about how LLMs operate. For reasons unbeknownst to me they fiercely defend the bot using all sorts of mental gymnastics. But seeing the severity of GPT's rambling, as shown in Dave's interaction, I think I better shut up. As a famous eastern philosopher used to say - never interfere when your enemy is busy making mistakes.