[x3d-public] removeNamedNode removes DEF children?

Patrick Dähne pdaehne at gmail.com
Tue Jul 12 02:35:06 PDT 2022



> Here is one last clarification. After all occurrences of a node are removed from a scene, can it still be readded as a USE, named node ? It appears so. In SAI terms, getNamedNode() does not rely on if a node is currently used in a scene ?
> 
> That means a named node may never be released from memory.
> 
> But unnaming such an unlinked node with removeNamedNode should make it safe to remove from memory ?

A node gets garbage collected when

a) it is no longer part of the scene graph, i.e. it is not a root node of a live scene, and it is not contained in the field of another live node, and

b) there is no reference from user code (either externally or in a Script node) to the node.

ROUTEs do not prevent nodes from getting garbage collected, as well as DEF names.

To answer your questions:

- You can re-add a node, because you still have a reference to it in your user code.

- A named node gets released from memory when it is no longer part of the scene graph and there is no reference to it in your user code.

Bye,

Patrick




More information about the x3d-public mailing list