c++-to-python swig caused memory leak! Related to Py_BuildValue and SWIG_NewPointerObj
- by usfree74
Hey gurus,
I have the following Swig code that caused memory leak.
PyObject* FindBestMatch(const Bar& fp) {
Foo* ptr(new Foo());
float match;
// call a function to fill the foo pointer
return Py_BuildValue(
"(fO)",
match,
SWIG_NewPointerObj(ptr,
SWIGTYPE_p_Foo,
…