vtk becomes slow and consumes more and more memory.

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

vtk becomes slow and consumes more and more memory.

Taron
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?
Reply | Threaded
Open this post in threaded view
|

Re: vtk becomes slow and consumes more and more memory.

Cory Quammen-2
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 <[hidden email]> 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
_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|

Re: vtk becomes slow and consumes more and more memory.

Taron
This post was updated on .
Hi Cory,

cloned the master today, build it with Visual Studio 2012 in 64bit Release mode. The problem persists:

Time for 1000: 0.686sec
Time for 1000: 1.499sec
Time for 1000: 2.268sec
Time for 1000: 3.231sec
Time for 1000: 4.431sec
etc.

Memory consume is also still an issue.

Edit:
Now i have tested the compiled exe on different machines:

All Computers have the same HArdware and Differ only by Graphic Adapter and OS:

Win7 64 - Geforce Titan - Problem Occures
Win7 64 - Radeon HD7800 - Problem Occures
Win7 64 - Geforce GTX 650 Ti - Problem does NOT occur
Win2012 Server 64 - IntelHD - Problem does NOT occur

This happens with the same exe and dlls. Very strange




Reply | Threaded
Open this post in threaded view
|

Re: vtk becomes slow and consumes more and more memory.

Taron
Hi All,

I found the issue. It seems that Bitdefender Antivirus software is somehow interferring with the program.
Thanks a lot.
Reply | Threaded
Open this post in threaded view
|

Re: vtk becomes slow and consumes more and more memory.

Cory Quammen-2
I'm glad you found it.

- Cory

On Mon, Aug 18, 2014 at 6:01 AM, Taron <[hidden email]> wrote:

> Hi All,
>
> I found the issue. It seems that Bitdefender Antivirus software is somehow
> interferring with the program.
> Thanks a lot.
>
>
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/vtk-becomes-slow-and-consumes-more-and-more-memory-tp5728227p5728244.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
_______________________________________________
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