GUI - cloning a huge load of node trees (SOLVED)

Hi,

For my game I have to clone (with gui.clone_tree) a lot of nodes. I dynamically clone nodes when they are on screen and destroy them when they are off screen.
I do that basically for hundreds of them, and I keep track of which nodes are on screen and off screen with a table. Each entry of this table contains just 4 numbers, and a node_tree, which is nil if the corresponding ui element is off screen.
But, at some point, the game crashes with the message “Not enough resources to clone the node tree”.

So, I’m wondering : is this crash related to my table becoming too big, or something else ?

Thanks

No, but I’m guessing you’re running out of nodes. Keep in mind that if you’re deleting and cloning nodes in the same frame the deleted ones will still count towards the total until next frame.

3 Likes

You can check your current node count (Gui.Nodes and friends) with the web profiler, see https://www.defold.com/manuals/debugging/#_web_profiler
If the node count is increasing over time, you need to check your code keeping track of what should be deleted.

4 Likes

Thank you, the profiler helped me a lot, especially the visual profiler, which permitted me to spot the places where I forgot to destroy some nodes.

5 Likes