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

vidyadhar vidyadhar at lucidindia.net
Mon Apr 25 23:13:09 EDT 2005


Hi,
Array->SetVoidArray(bytes,65536,1);
Instructs VTK not to free the 'bytes' array. Are freeing that yourself? If
not that may be the reason for observed behaviour.
HTH
Vidyadhar
----- Original Message -----
From: "Beau Sapach" <beau.sapach at ualberta.ca>
To: <vtkusers at vtk.org>
Sent: Tuesday, April 26, 2005 2:15 AM
Subject: [vtkusers] Am I using vtkImageData correctly? Seems like a
memoryleak....


> 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