I have a tree class in python3, each tree object has a reference to its parent and a list of references to its children.
In the main method there is a reference to the root of the tree. I tried to dereference the children of the root by saying root.children = [], but the RAM usage does not seem to go down. How can I clear the whole tree or a partial portion from memory? For those wondering this is important because the tree is very big and the RAM usage becomes too high.
p.s.: I believe that what is making the memory not being cleared is that after I remove the children from the root, depth 2 nodes have a reference to depth 3 nodes and vice-versa, and so on.