Re: Python C API String Memory Consumption

2009-04-10 Thread Hrvoje Niksic
Carl Banks writes: > On Apr 9, 11:23 pm, Hrvoje Niksic wrote: >> a...@pythoncraft.com (Aahz) writes: >> > BTW, note that if you're using Python 2.x, range(100) will cause >> > a "leak" because ints are never freed.  Instead, use xrange(). >> >> Note that using xrange() won't help with that p

Re: Python C API String Memory Consumption

2009-04-10 Thread Carl Banks
On Apr 9, 11:23 pm, Hrvoje Niksic wrote: > a...@pythoncraft.com (Aahz) writes: > > BTW, note that if you're using Python 2.x, range(100) will cause > > a "leak" because ints are never freed.  Instead, use xrange(). > > Note that using xrange() won't help with that particular problem. I think

Re: Python C API String Memory Consumption

2009-04-10 Thread Hrvoje Niksic
a...@pythoncraft.com (Aahz) writes: > BTW, note that if you're using Python 2.x, range(100) will cause > a "leak" because ints are never freed. Instead, use xrange(). Note that using xrange() won't help with that particular problem. -- http://mail.python.org/mailman/listinfo/python-list

Re: Python C API String Memory Consumption

2009-04-09 Thread Aahz
In article <41d95468-8f7a-4647-83e1-6df147744...@u8g2000yqn.googlegroups.com>, k3xji 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(100): > >... ss

Re: Python C API String Memory Consumption

2009-04-07 Thread Floris Bruynooghe
On Apr 7, 2:10 pm, John Machin wrote: > On Apr 7, 9:19 pm, MRAB wrote: > > > > > k3xji wrote: > > > Interestaing I changed malloc()/free() usage with PyMem_xx APIs and > > > the problem resolved. However, I really cannot understand why the > > > first version does not work. Here is the latest cod

Re: Python C API String Memory Consumption

2009-04-07 Thread Benjamin Peterson
Carl Banks gmail.com> writes: > However, Python apparently does leak a reference if passed a Unicode > object; PyArg_ParseTuple automatically creates an encoded string but > never decrefs it. (That might be necessary evil to preserve > compatibility, though. PyString_AS_STRING does it too.) Uni

Re: Python C API String Memory Consumption

2009-04-07 Thread John Machin
On Apr 7, 9:19 pm, MRAB wrote: > k3xji wrote: > > Interestaing I changed malloc()/free() usage with PyMem_xx APIs and > > the problem resolved. However, I really cannot understand why the > > first version does not work. Here is the latest code that has no > > problems at all: > > > static PyObjec

Re: Python C API String Memory Consumption

2009-04-07 Thread MRAB
k3xji wrote: Interestaing I changed malloc()/free() usage with PyMem_xx APIs and the problem resolved. However, I really cannot understand why the first version does not work. Here is the latest code that has no problems at all: static PyObject * penc(PyObject *self, PyObject *args) { Py

Re: Python C API String Memory Consumption

2009-04-07 Thread k3xji
Interestaing I changed malloc()/free() usage with PyMem_xx APIs and the problem resolved. However, I really cannot understand why the first version does not work. Here is the latest code that has no problems at all: static PyObject * penc(PyObject *self, PyObject *args) { PyObject * result

Re: Python C API String Memory Consumption

2009-04-07 Thread Carl Banks
On Apr 7, 12:01 am, k3xji 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(100): > > ...     ss = esauth.penc('sumer') > ... > > >>> for i in range(1000