[vtkusers] Deleting ImageData Inside Loop

David E DeMarle dave.demarle at kitware.com
Mon Jun 18 17:42:30 EDT 2012


On Mon, Jun 18, 2012 at 5:29 PM, matheus_viana <vianamp at gmail.com> wrote:
> Hi Guys,
>
> I've a code that looks like that:
>
> for (int i=100;i--;) {
>        vtkStructuredPointsReader *Reader = vtkStructuredPointsReader::New();
>        structured_dataset -> SetFileName("ImageData001.vtk");
>        structured_dataset -> Update();
>

Do you mean:
        vtkStructuredPointsReader *structured_dataset = ...

>        vtkImageData *ImageData = vtkImageData::New();
>        ImageData = structured_dataset -> GetOutput();
>        ImageData -> Update();

If so, call:
        structured_dataset->Delete()
here.

>
>        /**
>                working on the ImageData
>        **/
>
>        ImageData -> Delete();
> }
>
> This code used to work well in VTK4, but in VTK5 it crashes at line
> ImageData -> Delete(); Commenting this line the code runs well, but the
> memory is not released at each interaction.
>
> Do you guys know how to solve that? Is one possibility use the class
> vtkSmartPointer? If so, how to do that?
>
> Thanks in advance,
> Matheus Viana
>
> --
> View this message in context: http://vtk.1045678.n5.nabble.com/Deleting-ImageData-Inside-Loop-tp5713986.html
> Sent from the VTK - Users mailing list archive at Nabble.com.
> _______________________________________________
> 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