Alan Franzoni wrote: > I have a root node which is not referenced by any other node. So, I > created a "clear()" method which is called on all children (by calling > their clear() method" and then clears the set with the references of the > node itself.
Using the .clear() method on sets (or dictionaries) does not reduce the memory that the underlying hash tables use, it only removes references to the keys (and values) that the sets (and dictionaries) contain(s). If your sets used to be large, I could have sworn that you could force a resize down by adding some items to the set, but I seem to be mistaken: #memory use is 3440k s = set(xrange(1000000)) #memory use is 31,864k s.clear() #memory use is 15,460k s.add(0) s.remove(0) #memory use is 15,460k Then again, this may be an artifact of my operating system memory freeing semantics. As is usually the case, read the C source from svn.python.org/view (or some other means) for more information. - Josiah -- http://mail.python.org/mailman/listinfo/python-list