[Insight-users] Reference counting

Michael Kuhn michakuhn at gmx . ch
Thu, 14 Aug 2003 16:56:51 -0600


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