I have a Python code which constructs a quadtree from the root node up, introducing new nodes as necessary.
This quadtree needs to be continually reconstructed What I have done thus far is, each time the quadtree needs to be reconstructed, I reset the list of children of the root node to an empty list, and build the tree starting from the root.
My worry is that, all the nodes of the previous tree (besides the root node) will still exist in memory. The tree is reconstructed perhaps tens of thousands of times over the course of the program and contains perhaps 5000 nodes on average, so I wouldn't be suprised if the memory gets overloaded.
In order to not exceed memory limitations, wouldn't I have to delete all the previous nodes somehow? How might I do this?