Python memory deallocate
Tim N. van der Leeuw
tim.leeuwvander at nl.unisys.com
Thu May 11 13:40:01 CEST 2006
'del a' should remove 'a', as a reference to the tuple created by the
If that is also the last reference, it can now be garbage-collected.
Of course, the question is if you really need to allocate such a big
amount of memory. If you just need to iterate over some numbers, it's
better to use 'xrange' instead of 'range': 'xrange' will not create the
whole list of numbers in advance, but will create an iterator,
producing the desired numbers one by one. With such large ranges, this
will reduce memory consumption significantly.
More information about the Python-list