memory leak in python extension; mysqlclient & numpy

Fredrik Lundh fredrik at pythonware.com
Wed Oct 9 15:06:21 EDT 2002


John Hunter wrote:

> OK, found the leak.  The problem is that I need Py_DECREF my arrays
> after building them into the tuple for return, as in
>
> [ snip ]
>
>   tup =  Py_BuildValue("(OOO)", p,v,t);
>   Py_DECREF(p);
>   Py_DECREF(t);
>   Py_DECREF(v);
>   return tup;

or use the "N" specifier:

    return Py_BuildValue("(NNN)", p,v,t);

for details, see:

http://www.python.org/doc/current/ext/buildValue.html

</F>

<!-- (the eff-bot guide to) the python standard library:
http://www.pythonware.com/people/fredrik/librarybook.htm
-->





More information about the Python-list mailing list