[vtkusers] Memory leak in vtkMath

Mathieu Malaterre mathieu.malaterre at kitware.com
Mon Jan 9 11:42:09 EST 2006


Salut Sébastien,

   Nice catch ! Could you please add this as a bug to our bug tracker system located at:

   http://vtk.org/Bug

Thanks
Mathieu
Ps: You need an account to create new bug.

> 
> From: Sebastien Valette <sebastien.valette at creatis.insa-lyon.fr>
> Date: 2006/01/09 Mon AM 10:56:12 EST
> To: vtkusers at vtk.org
> Subject: [vtkusers] Memory leak in vtkMath
> 
> 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/
> 
> _______________________________________________
> This is the private VTK discussion list. 
> Please keep messages on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
> 




More information about the vtkusers mailing list