[Insight-users] Reference counting

Miller, James V (Research) millerjv at crd . ge . com
Fri, 15 Aug 2003 08:43:51 -0400


The ResampleImageFilter uses an interpolator.  When Update() is called
on the ResampleImageFilter, the ResampleImageFilter passes the input image
to the interpolator.  The interpolator keeps a handle to the image. So the
reference count is increased both when SetInput is called and when Update() 
is called. 

If you want the ResampleImageFilter to release its the bulk INPUT data
(pixels), 
call ReleaseDataOn() on the filter BEFORE the ResampleImageFilter prior to 
calling Update(). This will not change the reference count on the image
itself 
but merely forces the pipeline to free up the bulk data (pixels).

If you really want the reference counts to decrease, you can call 
filter->GetInterpolator()->SetImage( 0 ) to force the interpolator to
release
its handle on the data.




> -----Original Message-----
> From: Michael Kuhn [mailto:michakuhn at gmx . ch]
> Sent: Thursday, August 14, 2003 6:57 PM
> To: insight-users
> Subject: [Insight-users] Reference counting
> 
> 
> Hi,
> 
> we are having memory problems within our application. 
> Therefore we are 
> trying to get rid of memory that is at the beginning of the pipeline. 
> We've noticed that the reference count on an image is increased after 
> calling a ResampleImageFilter->SetInput() method as well as after the 
> call to the filter's Update() method.
> 
>     cout << "image: rc at line number " << __LINE__ << ": " <<
>         image->GetReferenceCount() << endl;
>     filter->SetInput(image);
>     cout << "image: rc at line number " << __LINE__ << ": " <<
>         image->GetReferenceCount() << endl;
> [...]
>     cout << "image: rc at line number " << __LINE__ << ": " <<
>         image->GetReferenceCount() << endl;
>     filter->Update();
>     cout << "image: rc at line number " << __LINE__ << ": " <<
>         image->GetReferenceCount() << endl;
> 
> Why is the reference count to the image increased by calling the 
> Update() method?
> 
> Thanks,
> 
> Michael
> 
> 
> _______________________________________________
> Insight-users mailing list
> Insight-users at itk . org
> http://www . itk . org/mailman/listinfo/insight-users
>