Author: bugman Date: Thu Mar 16 08:10:56 2006 New Revision: 2394 URL: http://svn.gna.org/viewcvs/relax?rev=2394&view=rev Log: The addition of Py_DECREF() calls to try to prevent the memory leak present in the relaxation curve-fitting C modules. Modified: 1.2/maths_fns/relax_fit.c Modified: 1.2/maths_fns/relax_fit.c URL: http://svn.gna.org/viewcvs/relax/1.2/maths_fns/relax_fit.c?rev=2394&r1=2393&r2=2394&view=diff ============================================================================== --- 1.2/maths_fns/relax_fit.c (original) +++ 1.2/maths_fns/relax_fit.c Thu Mar 16 08:10:56 2006 @@ -59,8 +59,10 @@ relax_times = (double *) numpy_relax_times->data; scaling_matrix = (double *) numpy_scaling_matrix->data; + /* Increment the reference count for the python object None */ + Py_INCREF(Py_None); + /* Return nothing */ - Py_INCREF(Py_None); return Py_None; } @@ -91,6 +93,9 @@ /* Back calculated the peak intensities */ exponential(); + + /* Deallocate the memory used by the parameters */ + Py_DECREF(numpy_params); /* Calculate and return the chi-squared value */ return Py_BuildValue("f", chi2()); @@ -126,13 +131,15 @@ /* Test code (convert aaa to a Numeric array */ - /* aaa_numpy = (PyArrayObject *) PyArray_FromDimsAndData(1, num_params, PyArray_DOUBLE, aaa_pointer); */ aaa_numpy = (PyArrayObject *) PyArray_FromDims(1, &num_params, PyArray_DOUBLE); aaa_pointer = (double *) aaa_numpy->data; /* Fill the Numeric array */ for (i = 0; i < 2; i++) aaa_pointer[i] = aaa[i]; + + /* Deallocate the memory used by the parameters */ + Py_DECREF(numpy_params); return NULL; return PyArray_Return(aaa_numpy);