[Insight-users] how to realease the memory of a filter?
Alberto Bert
bert at isi.it
Thu Mar 16 14:30:32 EST 2006
On Mar 16, 2006 at 01:28:10PM -0500, Karthik Krishnan wrote:
> Andinet Enquobahrie wrote:
> >>As I've understood, most of the filters produce a new image, "doubling"
> >>the memory. I would like to be able to release the memory as soon I
> >>don't need it any more. For example:
> >>
> >>itkFilter1->SetInput( InputImage );
> >>itkFilter1->Update();
> >>TmpImage = itkFilter1->GetOutput();
> >>
> >>MyClassObject.SetInput( TmpImage );
> >>OutputImage = MyClassObject.GetOutput();
> >>
> >>// at this point I don't need any more InputImage
> >>
> Two options here:
>
> 1. Set the ReleaseDataFlagOn() on the filter from which InputImage came
> from. ie . not itkFilter1, but the one before that. This will force that
> filter to release its bulk data downstream, once itkFilter1 gobbles it.
>
> 2. If you don't have InputImage being produced by a filter, you can
> mererly set it to 0. *Do not* ever delete smart pointers. The idea of
> reference counting is that the smart pointer should be smart enough to
> do it on its own.
>
> InputImage = 0; should do it.
Thank you very much. I didn't know it was as simple as " = 0 ".
I'll try it that way.
Alb.
More information about the Insight-users
mailing list