<div dir="ltr">Hi Weiguang,<div>Take a look at </div><div><a href="http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers">http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers</a><br></div><div>This might clarify some of your questions. You have to remember that the reference count is stored in the objects themselves unlike the c++ shared_ptr where the reference count is stored in the shared pointer object.</div><div><br></div><div>For the first question: do you assign the object to a vtk smart pointer? That would explain why the reference count is 2.</div><div>For the rest of the questions: when you set up the pipeline there are other objects involved besides the filter themselves, so it is harder to understand of the reference count.</div><div><br></div><div>Also you can set VTK_DEBUG_LEAKS when you build VTK if you are concerned about leaks.</div><div><br></div><div>Dan</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Oct 15, 2015 at 4:13 PM, Weiguang guan <span dir="ltr"><<a href="mailto:guanw@rhpcs.mcmaster.ca" target="_blank">guanw@rhpcs.mcmaster.ca</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I find, in debug mode, that the ReferenceCount of a vtkImageEllipsoidSource object becomes 2 right after being initiated (vtkImageEllipsoidSourc::New()). It should be 1 not 2, right? How could this happen?<br>
<br>
My second question is --- when you make a connection A->SetInputConnection(B->GetOutputPort()); Whose reference count will be increased by 1, A or B? I think B's reference count should be increased because it is used by A. But what I find is just the opposite.<br>
<br>
My third question is about setting up more than 1 connection for a filter. Taking vtkImageMathematics as an example, I do<br>
vtkImageMathematics* A = vtkImageMathematics::New();<br>
A->SetInputConnection(0, B1->GetOutputPort();<br>
A->SetInputConnection(0, B2->GetOutputPort();<br>
<br>
I find that the reference count of A gets increased by the first SetInputConnection() call only.<br>
<br>
Can someone explain how reference counting works in VTK? Thanks.<br>
<br>
Best,<br>
Weiguang<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the VTK FAQ at: <a href="http://www.vtk.org/Wiki/VTK_FAQ" rel="noreferrer" target="_blank">http://www.vtk.org/Wiki/VTK_FAQ</a><br>
<br>
Search the list archives at: <a href="http://markmail.org/search/?q=vtkusers" rel="noreferrer" target="_blank">http://markmail.org/search/?q=vtkusers</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://public.kitware.com/mailman/listinfo/vtkusers" rel="noreferrer" target="_blank">http://public.kitware.com/mailman/listinfo/vtkusers</a><br>
</blockquote></div><br></div>