how to explain this memory usage

Andrew Kuchling akuchlin at mems-exchange.org
Thu Apr 26 10:20:20 EDT 2001


javalist <javalist at 21cn.com> writes:
>        also the interpreter has 20M in memory,but seems python knows they are
>        pointing nothing and reuse these 20M when I try again allocating more
>        object in python,it didn't increase memory until the first 20M is
>        occupied by the new allocated object

This is also dependent on your platform's malloc.  The malloc used on
Linux, for example, uses mmap() for allocations above a given size,
and on freeing an mmap()'ed area, the process size drops.  For
example, I just tried creating a 20Mb string, watched the process size
jumped appropriately, then deleted it and watched the process go back
to around 2Mb.  20Mb of smaller objects probably won't have this
pleasant predictability.  I'm not sure how enabling pymalloc would
change this picture.

--amk




More information about the Python-list mailing list