[vtkusers] Potential memory leak on render

Jonathan Morra jonmorra at gmail.com
Fri Apr 27 12:23:19 EDT 2012


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;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120427/613d60c7/attachment.htm>


More information about the vtkusers mailing list