Memory leak when using a C++ module for Python

Ivan Illarionov ivan.illarionov at
Tue Dec 16 21:28:51 CET 2008

On Dec 11, 8:35 pm, Jaume Bonet < at> wrote:
>         //Here we take the info coming from python and transform it
> into a vector (will allow us to work with numbers instead of
>         // strings) and shareInt which is an array of sets (form
> std::set)
>         vector<string> translator = string2int
> (shareIntPy,root,shareInt,pSize,max);

I guess if there are any problems with Python/C API in your example
they are in string2int function. How do you retrieve Python data from
'shareIntPy' Python object? If you have memory leaks you probably
forget to Py_DECREF something retrieved with Python/C API functions
that return new references (like PyObject_GetAttrString).


More information about the Python-list mailing list