Python memory usage

Klaas mike.klaas at
Wed Nov 8 07:21:41 CET 2006

placid wrote:
> Hi All,
> Just wondering when i run the following code;
> for i in range(1000000):
>      print i
> the memory usage of Python spikes and when the range(..) block finishes
> execution the memory usage does not drop down. Is there a way of
> freeing this memory that range(..) allocated?

Python maintains a freelist for integers which is never freed (I don't
believe this has changed in 2.5).  Normally this isn't an issue since
the number of distinct integers in simultaneous use is small (assuming
you aren't executing the above snippet).


More information about the Python-list mailing list