[Insight-users] Re: how to release the memory of a filter

Andrew Li andrew.li at synarc.com
Thu Mar 16 16:32:30 EST 2006


Hi, Karthik:

Your answers to Alb helped me too.
I have some additional questions:

What will happen if I do the following? (Assuming that TmpImage is also
a smart pointer)

>> ...
>>
>> itkFilter1->SetInput( InputImage );
>> itkFilter1->Update();
>> TmpImage = itkFilter1->GetOutput();
>>

InputImage = 0; // added as suggested by Karthik
itkFilter1 = 0; // added by Andrew #1

>> MyClassObject.SetInput( TmpImage );
>> OutputImage = MyClassObject.GetOutput();
>>

TmpImage = 0; // added by Andrew #2

>> ...
>>


Is there any advantage or problem from this inserted line? 
	itkFilter1 = 0; // added by Andrew #1
I assume that this line will force everything pointed by itkFilter1 to
be released except the object pointed by TmpImage. Is it correct?

And the remaining resources: the object pointed by TmpImage will be
release at inserted line #2: 
	TmpImage = 0; // added by Andrew #2
And, thus, there will be no problem such as memory leaks.
 
Thank you very much for your help!

-Andrew
 
--------------------------------------------------------

This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information.Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message. If you are the intended recipient, please be advised that the content of this message is subject to access, review and disclosure by the sender's Email System Administrator.
--------------------------------------------------------


More information about the Insight-users mailing list