[vtkusers] Am I using vtkImageData correctly? Seems like a memory leak....

Beau Sapach beau.sapach at ualberta.ca
Mon Apr 25 16:45:31 EDT 2005


Hello everyone,

I have an application in C++ that loads a number of images from file like
this:


vtkUnsignedShortArray * Array = vtkUnsignedShortArray::New();
vtkImageData * Image = vtkImageData::New();
char * bytes = new char[131072];
File.Read(bytes,131072);
Array->SetVoidArray(bytes,65536,1);
Image->SetExtent(0,255,0,255,0,0);
Image->SetScalarTypeToUnsignedShort();
Image->GetPointData()->SetScalars(Array);
Array->Delete();
return Image;


Later on when I am loading in a new set of images I call ->Delete() on each
of the vtkImageData objects I created in the above function.  Will this be
enough to clear all of the memory?  My application seems to grow in size by
aproximately a full set of images everytime I reload, so somewhere scalars
are not being deleted.... Am I using SetVoidArray() incorrectly or
something?

----------------------------------------
Beau Sapach
Network Administrator
Biomedical Engineering
University of Alberta
Phone: (780) 492-8098
Fax: (780) 492-8259
Email: beau.sapach at ualberta.ca
----------------------------------------





More information about the vtkusers mailing list