[vtkusers] Trouble understanding memory leak

Taron taron2000 at gmx.de
Fri May 23 03:46:46 EDT 2014


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.


More information about the vtkusers mailing list