[vtkusers] Reference counting in 6.3

Dan Lipsa dan.lipsa at kitware.com
Wed Oct 21 15:11:00 EDT 2015


Hi Weiguang,
Take a look at
http://www.vtk.org/Wiki/VTK/Tutorials/SmartPointers
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.

For the first question: do you assign the object to a vtk smart pointer?
That would explain why the reference count is 2.
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.

Also you can set VTK_DEBUG_LEAKS when you build VTK if you are concerned
about leaks.

Dan


On Thu, Oct 15, 2015 at 4:13 PM, Weiguang guan <guanw at rhpcs.mcmaster.ca>
wrote:

> Hello,
>
> 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?
>
> 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.
>
> My third question is about setting up more than 1 connection for a filter.
> Taking vtkImageMathematics as an example, I do
> vtkImageMathematics* A = vtkImageMathematics::New();
> A->SetInputConnection(0, B1->GetOutputPort();
> A->SetInputConnection(0, B2->GetOutputPort();
>
> I find that the reference count of A gets increased by the first
> SetInputConnection() call only.
>
> Can someone explain how reference counting works in VTK? Thanks.
>
> Best,
> Weiguang
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the VTK FAQ at:
> http://www.vtk.org/Wiki/VTK_FAQ
>
> Search the list archives at: http://markmail.org/search/?q=vtkusers
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/vtkusers
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/vtkusers/attachments/20151021/e1cc7850/attachment.html>


More information about the vtkusers mailing list