[vtkusers] Ref Count Madness
Valerie R Coffman
valerie.coffman at nist.gov
Mon Jun 2 15:55:33 EDT 2008
Hello,
I'm writing an application in C++.
I have an object which uses a pipeline that typically consists of one derived of
vtkImageReader2 such as vtkTIFFReader plus a few other classes derived from
vtkImageAlgorithm such as vtkImageAppendComponents. The exact number and types
of objects depends on run-time decisions. I'm storing pointers to these objects
in an std::vector. I would like to free all the memory used by these
vtkImageAlgorithm objects and their outputs when I delete my object. I'm trying
to loop over my vector and run Delete on each of the vtkImageAlgorithm objects
which were created with New. What I've noticed is that something like
vtkImageAppendComponents starts with a ReferenceCount of 1 which increments to 2
when the input is added, as expected. However vtkTIFFReader has a
ReferenceCount of 2 immediately after it is created. The result seems to be
that none of the pipeline objects reach a reference count of 0 and get deleted.
Why does the ReferenceCount of the vtkTIFFReader start at 2 and how can I
decrement it to 0 in my destructor?
Thanks,
Valerie
More information about the vtkusers
mailing list