[vtkusers] Question about Reference counting!!
namgyun Lee
ggang56 at gmail.com
Wed Aug 27 02:00:13 EDT 2008
Hi, everyone!
I am a new VTK user and trying to figure out how vtk reference counting is
working.
When I saw the result of simple code, I was kind of surprised.
This is the sample code that I used to test reference counting.
// test for reference counting
vtkImageData* vtkImage = vtkImageData::New();
std::cout << "Reference count: " << vtkImage->GetReferenceCount() <<
std::endl;
std::cout << "Reference count: " << vtkImage->GetReferenceCount() <<
std::endl;
vtkImageReslice* reslicer = vtkImageReslice::New();
reslicer->SetInput (vtkImage);
std::cout << "Reference count: " << vtkImage->GetReferenceCount() <<
std::endl;
reslicer->Update();
std::cout << "Reference count: " << vtkImage->GetReferenceCount() <<
std::endl;
reslicer->Delete();
std::cout << "Reference count: " << vtkImage->GetReferenceCount() <<
std::endl;
The output was 1 1 3 3 3!!!
It seems like the reference count increases before the actual pipeline
finishes updating.
I always thought that if the container(reslicer) is deleted, the reference
count of vtkImage decreases as a result. And why did the reference become 3
instead of 2?
Am I thinking wrong? Could anyone explain about this?
Thank you so much.
Sincerely,
Nam
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20080826/419d4e50/attachment.htm>
More information about the vtkusers
mailing list