[SciPy-user] memory leak with Python/C API

Daniel Jiménez dani.berzas at gmail.com
Mon Oct 3 07:42:19 EDT 2005


Hi, every one,
First sorry if this is not the right the place to ask this question.

I'm having memory leak when working with Python/C API.

A big amount of data is generated in C and transfered to Python, but
after use the memory is not freed. The program run until the OS kill the
process.

I'm working with Ubuntu-Warty, Python 2.3.4,
[GCC 3.3.4 (Debian 1:3.3.4-9ubuntu5)] on linux2
with scipy 0.3.2


The C program goes as follows:
{
Load the initial data (list of arrays) with PyArg_ParseTuple().
ExitList = PyList_New(..);
HpList = PyList_New(n_esp);
loop_1
  { hp = calloc()
    (compute hp)
    PyList_SET_ITEM(HpList,i,...(char *)hp) );
  }

PyList_SET_ITEM(ExitList,0,(PyObject *)HpList);

return ExitList;
}

In Python I activate garbage collector and delelete ExitList. But the
used memory continues increasing until the process is killed.

I've also used valgring but without results.

I'll really appreciate any suggestion on this topic.
Shall I try wrapping C with SWIG, Boost, weave, Pyrex, etc. ?.
Thanks for your help.

Dani.






More information about the SciPy-User mailing list