Queue Free might not be working?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By ryanrom5

Hello Everyone,

I just want to be absolutely sure I don’t have a memory leak in my game.

To summarize, when I open an ability menu, I iterate though an array of abilities and generate new instances of buttons for each ability. When I close the ability menu I call queue free on each button to remove them. On the surface it’s working fine, the buttons are generated and destroyed.

However when I checked the “remote” debug menu to confirm, each batch of new buttons continues to increment from the previously destroyed buttons.

For example “@@1, @@2, @@3, @@4” are created then destroyed.
But the next batch of created buttons will read “@@5, @@6, @@7, @@8” and the ones after that will read “@@9, @@10, @@11, @@12” and so on.

Am I properly deleting my button instances? I am calling queue free and the buttons are being successfully removed, why is it still incrementing?

Thank you very much

add groups to the buttons? (“@@1, @@2, @@3, @@4”)
Groups — Godot Engine (stable) documentation in English

ramazan | 2022-03-06 08:18

I can’t guarantee without digging into engine code, but I think queue_free is working fine if the behavior is okay to you. I think the incrementing is just a runtime habit of sorts – what reason is there really to reset it I guess? If the old nodes aren’t in the tree anywhere, then they shouldn’t be loaded and queue_free is meant to responsibly clear that memory.

i.e. if it ain’t broke don’t fix it. only a profiler could try to tell you if it’s broke at this point

w411-3 | 2022-03-09 02:30

That makes sense to me, thank you!

ryanrom5 | 2022-03-15 01:30