why python cache the string > 256?

Diez B. Roggisch deets at nospam.web.de
Mon Oct 26 21:03:58 CET 2009


s7v7nislands schrieb:
> hi all:
> 
> test.py
> #!/usr/bin/python
> a = []
> for i in xrange(1000000):
>     a.append('a'*500)
> 
> 
> $python -i test.py     #virt mem 514m in top output
>>> del a                   #virt mem 510m
> 
> why python cache these string?
> In source, I see when object size > SMALL_REQUEST_THRESHOLD, python
> would use malloc.
> also use free() when string refcount == 0.
> 
> do I miss somethong?

http://effbot.org/pyfaq/why-doesnt-python-release-the-memory-when-i-delete-a-large-object.htm

Diez



More information about the Python-list mailing list