Python C API String Memory Consumption

Aahz aahz at pythoncraft.com
Thu Apr 9 22:17:34 EDT 2009


In article <41d95468-8f7a-4647-83e1-6df147744467 at u8g2000yqn.googlegroups.com>,
k3xji  <sumerc at gmail.com> wrote:
>
>When I run the following function, I seem to have a mem leak, a 20 mb
>of memory
>is allocated and is not freed. Here is the code I run:
>
>>>> import esauth
>>>> for i in range(1000000):
>
>...     ss = esauth.penc('sumer')
>...
>>>> for i in range(1000000):
>
>...     ss = esauth.penc('sumer')
>...

BTW, note that if you're using Python 2.x, range(1000000) will cause a
"leak" because ints are never freed.  Instead, use xrange().
-- 
Aahz (aahz at pythoncraft.com)           <*>         http://www.pythoncraft.com/

Why is this newsgroup different from all other newsgroups?



More information about the Python-list mailing list