[vtkusers] Deleting imagedata

prieto at creatis.insa-lyon.fr prieto at creatis.insa-lyon.fr
Wed Mar 24 13:40:20 EDT 2010


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




More information about the vtkusers mailing list