Python memory usage
placid
Bulkan at gmail.com
Wed Nov 8 01:24:40 EST 2006
Klaas wrote:
> 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).
Actually i am executing that code snippet and creating BeautifulSoup
objects in the range() (now xrange() ) code block.
Cheers
More information about the Python-list
mailing list