From: Daniel W. <dan...@gm...> - 2010-06-02 22:20:46
|
It seems that the find() method (lin 2986 in in Src/ll_mat.c) has a memory leak. Calling PyDECREF on a_row, a_col and a_val fixes this issue. I propose the following change: $ svn diff Index: Src/ll_mat.c =================================================================== --- Src/ll_mat.c (revision 168) +++ Src/ll_mat.c (working copy) @@ -2987,6 +2987,7 @@ /* Convert an LL matrix into coordinate format */ + PyObject *returnTuple; PyArrayObject *a_row, *a_col, *a_val; /* Matrix in coordinate format */ npy_intp dmat[1]; /* Dimension descriptor */ int *pi, *pj; /* Intermediate pointers to matrix data */ @@ -3014,10 +3015,16 @@ } } - return Py_BuildValue( "OOO", - PyArray_Return( a_val ), - PyArray_Return( a_row ), - PyArray_Return( a_col ) ); + returnTuple = Py_BuildValue( "OOO", + PyArray_Return( a_val ), + PyArray_Return( a_row ), + PyArray_Return( a_col ) ); + + Py_DECREF(a_row); + Py_DECREF(a_col); + Py_DECREF(a_val); + + return returnTuple; } /*********************************/ If no one has any particular objection, I'll add that changes to to branches/1_1_x and merge them to trunk/. Cheers -- Daniel Wheeler |