[vtkusers] Memory leak

Jothybasu Selvaraj jothybasu at gmail.com
Tue May 15 10:38:45 EDT 2012


Once I have done this step

 vtkPNGReader* reader = vtkPNGReader::New();
 reader->SetFileName("/home/
doriad/test.png");
 vtkSmartPointer<vtkImageData> img = vtkSmartPointer<vtkImageData>::New();
 img->DeepCopy(reader->GetOutput());

 reader->Delete();

Is it safe to do?

img->DeepCopy(*reader2*->GetOutput());//Some other reader

Thanks

Jothy




On Tue, May 15, 2012 at 3:33 PM, David Doria <daviddoria at gmail.com> wrote:

> You would keep the data and get rid of the reader like this:
>
> #include <vtkImageData.h>
> #include <vtkSmartPointer.h>
> #include <vtkPNGReader.h>
>
> int main(int argc, char *argv[])
> {
>  vtkPNGReader* reader = vtkPNGReader::New();
>  reader->SetFileName("/home/doriad/test.png");
>  vtkSmartPointer<vtkImageData> img = vtkSmartPointer<vtkImageData>::New();
>  img->DeepCopy(reader->GetOutput());
>
>  reader->Delete();
>
>  std::cout << img->GetNumberOfScalarComponents() << std::endl;
>
>  return 0;
> }
>
> David
>



-- 
Jothy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20120515/28b319d9/attachment.htm>


More information about the vtkusers mailing list