Free Memory

Patrick Mullen saluk64007 at gmail.com
Fri May 9 11:44:21 EDT 2008


I had some very interesting results with this code to do what is asked:

for key in globals().keys():
    del globals()[key]
for key in locals().keys():
    del locals()[key]

It might be better to reverse the two steps, I didn't give it much thought.
Anyway, when this is done, all of the builtins spill into globals and locals
(since __builtin__ was deleted).  I thought that was interesting.

It did have the effect that is asked for, although there may be more
unintended consequences.  Also if any objects are attached to any of the
builtins I expect they will still be around.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20080509/e1bb0182/attachment.html>


More information about the Python-list mailing list