[vtkusers] Trouble understanding memory leak

Taron taron2000 at gmx.de
Fri May 23 02:59:44 EDT 2014


Hello everyone,

I encountered a memory leak in my application and pinned it down that it is
something related to vtk.
I'm using vtk 6.1.0 on Windows 7 with Visual Studio 2012 all in 64bit.

I wrote a minimal example to figure out whats happening, but so far i have
no good clue:

#include <vtkSmartPointer.h>
#include <vtkImageMapToColors.h>
#include <vtkImageData.h>
#include <vtkLookupTable.h>

int main(int argc, char *argv[])
{
    vtkSmartPointer<vtkImageMapToColors> imageColor =
vtkSmartPointer<vtkImageMapToColors>::New();
    vtkSmartPointer<vtkLookupTable> lut =
vtkSmartPointer<vtkLookupTable>::New();
    imageColor->SetLookupTable(lut);
    int c=0;

    while (c != '.'){
         c = getchar();
         for(size_t i=0; i<100; ++i){
             vtkSmartPointer<vtkImageData> test =
vtkSmartPointer<vtkImageData>::New();
             imageColor->SetInputData(test);
             imageColor->Update();
         }
    }
    return 0;
}

Every time this for loop runs it allocates some MB of memory, but doesn't
free anything. It seems that everything here is correctly destroyed but it
still leaks memory. Maybe some internal object created by the pipeline has
some wierd reference loop which prevents it from beeing deleted properly. If
you have any suggestions whats going on here or whats wrong, please share
it.




--
View this message in context: http://vtk.1045678.n5.nabble.com/Trouble-understanding-memory-leak-tp5727213.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list