Memory leak when using a C++ module for Python

Ivan Illarionov ivan.illarionov at gmail.com
Tue Dec 16 15:28:51 EST 2008


On Dec 11, 8:35 pm, Jaume Bonet <jaume.bo... at gmail.com> wrote:
<snip>
>         //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).

Ivan



More information about the Python-list mailing list