[vtkusers] Potential memory leak on render

Xiaofeng Z xf10036 at hotmail.com
Fri Apr 27 12:46:17 EDT 2012


How did you measure the memory usage?

On Apr 27, 2012, at 12:23 PM, "Jonathan Morra" <jonmorra at gmail.com> wrote:

> I'm running the following code on Windows 7 (both x86 and x64), and have noticed the following memory usages.  I think this implies some memory leak in the render call to VTK.  Can someone please let me know if they see this as well, and if so how to fix it.
> 
> Thanks
> 
> Here are my results
> 0 Renders -- 9.852 M
> 1 Render -- 29.28 M (I'm not sure if this jump is to be expected)
> 10 Renders -- 29.76 M
> 100 Renders -- 30.404 M
> 1000 Renders -- 31.172 M
> 10000 Renders -- 36.56 M
> 100000 Renders -- 44.276 M
> 
> Here is the code
> 
> // I tested all these memory problems by putting a break point on the return0; line and noting the memory in the Windows Task Manager.
> int main(int argc, char *argv[]) {
>  vtkSmartPointer<vtkImageData> imageData =
>    vtkSmartPointer<vtkImageData>::New();
>  imageData->SetExtent(0, 100, 0, 100, 0, 100);
>  imageData->SetOrigin(0, 0, 0);
>  imageData->SetSpacing(1, 1, 1);
>  imageData->AllocateScalars();
>  imageData->GetPointData()->GetScalars()->FillComponent(0, 0);
>  vtkSmartPointer<vtkImageViewer2> imageViewer =
>    vtkSmartPointer<vtkImageViewer2>::New();
>  imageViewer->SetInput(imageData);
>  int numRenders = 100000;
>  for (int i=0; i<numRenders; ++i) {
>    imageViewer->Render();
>  }
>  return 0;
> }
> _______________________________________________
> 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



More information about the vtkusers mailing list