[vtkusers] Trouble understanding memory leak

Bill Lorensen bill.lorensen at gmail.com
Fri May 23 10:14:06 EDT 2014


I just ran your test code with valgrind and there were no memory leaks detected…


On Fri, May 23, 2014 at 3:46 AM, Taron <taron2000 at gmx.de> wrote:
> Ok to make the example even simpler every thing is allocated in the scope of
> the for loop, so everything should be destroyed each iteration, which it is
> not (according to monitoring the usage of memory used by the application):
>
> #include <vtkSmartPointer.h>
> #include <vtkImageMapToColors.h>
> #include <vtkImageData.h>
> #include <vtkLookupTable.h>
>
> int main(int argc, char *argv[])
> {
>     int c=0;
>
>     while (c != '.'){
>          c = getchar();
>          for(size_t i=0; i<100; ++i){
>              vtkSmartPointer<vtkImageMapToColors> imageColor =
> vtkSmartPointer<vtkImageMapToColors>::New();
>              vtkSmartPointer<vtkLookupTable> lut =
> vtkSmartPointer<vtkLookupTable>::New();
>              imageColor->SetLookupTable(lut);
>              vtkSmartPointer<vtkImageData> test =
> vtkSmartPointer<vtkImageData>::New();
>              imageColor->SetInputData(test);
>              imageColor->Update();
>          }
>     }
>     return 0;
> }
>
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Trouble-understanding-memory-leak-tp5727213p5727215.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers



-- 
Unpaid intern in BillsBasement at noware dot com


More information about the vtkusers mailing list