[Insight-users] how to realease the memory of a filter?

Karthik Krishnan Karthik.Krishnan at kitware.com
Thu Mar 16 13:28:10 EST 2006


Andinet Enquobahrie wrote:

>
>> Hi all,
>>
>> I'm working with big images (CTi and MRI) and I've got several 
>> filters in
>> a pipeline + some other processing classes I wrote (not with the ITK
>> organization, too bad... ).
>> 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.

>> ...
>>
>> I tryed with: Delete() but at the end of the execution it gives me a
>> SegFault I guess cause itk is trying to release the memory I already
>> released...
>>
>>  
>>
>
> Turn on the ReleaseDataFlag...
>
> itkFilter1->ReleaseDataFlagOn();
>
> -Andinet
>
>> What am I doing wrong?
>>
>> Thank you,
>> cheers
>> Alberto
>> _______________________________________________
>> Insight-users mailing list
>> Insight-users at itk.org
>> http://www.itk.org/mailman/listinfo/insight-users
>>
>>
>>  
>>
>
>
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk.org
> http://www.itk.org/mailman/listinfo/insight-users
>


More information about the Insight-users mailing list