[vtkusers] Deleting imagedata

Darshan Pai darshanpai at gmail.com
Fri Mar 26 14:51:38 EDT 2010


You can try the UnregisterAllOutputs() function before you call the
Delete();

or else use vtkSmartPointer to define your imageData

On Wed, Mar 24, 2010 at 1:40 PM, <prieto at creatis.insa-lyon.fr> wrote:

> Hello vtkUsers
>
> I have an application where I can load images and show them in a viewer
> and execute different filters etc.
> Everything goes fine in the application until I want to work with a second
> image.
> After I have load the image I've notice the application does not
> deallocate the previous image, if I continue to load other images, it
> starts eating memory to the point it crashes or gives unexpected
> behaviour.
> I have checked the reference count of the previous image and it always
> gives me 3 references even after I have set the new image into the
> application.
> I have tried many things to deallocate the old image without succeed for
> example:
>
> //I have an attribute from the class somewhere
> vtkImageData* _oldimg;
>
> ...
> //somewhere in the code after I have set the new image I've tried things
> like
> _oldimg->Delete();
> //Or
> _oldimg->SetReferenceCount(0);
> //Or the previous both
> //Or
> vtkGarbageCollector::UnRegister(_oldimg);
>
>
> etc.....
>
> The application either does nothing and continues to eat memory or it
> gives assertions or segmentation faults.
>
> Any help will be really appreciate it.
>
> Thank you
>
> _______________________________________________
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100326/855d8b68/attachment.htm>


More information about the vtkusers mailing list