[vtkusers] vtk becomes slow and consumes more and more memory.

Cory Quammen cory.quammen at kitware.com
Sun Aug 17 16:56:35 EDT 2014


Hi,

I cannot confirm the behavior you report on either linux or using
Visual Studio 2008 64-bit using VTK master in either Debug or Release
mode:

Time for 1000: 1.629sec
Time for 1000: 1.601sec
Time for 1000: 1.604sec
Time for 1000: 1.595sec
Time for 1000: 1.603sec
Time for 1000: 1.606sec

Can you try VTK master and see if that fixes the issues you report?

Thanks,
Cory

On Fri, Aug 15, 2014 at 5:05 AM, Taron <taron2000 at gmx.de> wrote:
> Hi there, this is a follow-up to my memory leak question, which in fact is
> not a "real" memory leak but something different. I'm using VTK 6.1 on
> Windows 7 x64 compiled Visual Studio 2012 in 64Bit.
>
> My problem is that everytime I create objects in vtk and call update on them
> it takes more and more memory and runs longer and longer. Consider this
> code:
>
> #include <vtkImageConstantPad.h>
> #include <vtkImageData.h>
> #include <ctime>
>
> int main(int argc, char *argv[])
> {
>     int c=0;
>     clock_t start;
>     size_t iterations = 1000;
>     while (c != '.'){
>          c = getchar();
>          start = clock();
>          for(size_t i=0; i<iterations; ++i){
>              vtkImageConstantPad* pad = vtkImageConstantPad::New();
>              vtkImageData* test = vtkImageData::New();
>              test->SetExtent(0,1,0,1,0,1);
>              test->AllocateScalars(VTK_FLOAT,1);
>              pad->SetInputData(test);
>              pad->SetOutputWholeExtent(0,2,0,2,0,2);
>              pad->Update(); //this is what makes it bad
>              pad->Delete();
>              test->Delete();
>          }
>          std::cout << "Time for " << iterations << ": " <<
> static_cast<double>(clock() - start) / CLOCKS_PER_SEC << "sec" << std::endl;
>     }
>     return 0;
> }
>
>
> The output:
>
> Time for 1000: 0.816sec
> Time for 1000: 1.879sec
> Time for 1000: 3.454sec
> etc.
>
> It takes longer with every call to update and consumes more memory, but all
> instances are deleted in the for-scope. So this seems to create some sort of
> objects and puts into an update pipeline, but does not remove them later
> internally. Can anyone confirm this behavior and other platforms and, how to
> fix that?
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/vtk-becomes-slow-and-consumes-more-and-more-memory-tp5728227.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://public.kitware.com/mailman/listinfo/vtkusers


More information about the vtkusers mailing list