[vtkusers] Memory leak in vtkMath
Sebastien Valette
sebastien.valette at creatis.insa-lyon.fr
Mon Jan 9 10:56:12 EST 2006
Hi,
I just would like to point out a memory leak in the vtkMath class (I
checked the cvs repository and the bug still exists)
in the method int vtkMath::SolveLeastSquares(int numberOfSamples, double
**xt, int xOrder,
double **yt, int yOrder, double **mt)
some intermediates variables are allocated, bot the memory is not always
freed after.
reason:
- when the execution was fine (and the method returns 1), the variables
are correctly swept out.
- when a problem occured (end the method returns 0), no variable is
freed, and the leak occurs.
Thus, it would be wise to add those lines:
***********begin code**************
// clean up:
// set up intermediate variables
for (i = 0; i < xOrder; i++)
{
delete [] XXt[i];
delete [] XXtI[i];
delete [] XYt[i];
}
delete [] XXt;
delete [] XXtI;
delete [] XYt;
*************end code *************
just the return(0); in the method.
Sincerely,
Sébastien Valette
--
http://www.creatis.insa-lyon.fr/~valette/
More information about the vtkusers
mailing list