[vtkusers] SetInputData() vs SetInputConnection()

Berk Geveci berk.geveci at kitware.com
Tue Apr 29 10:38:38 EDT 2014


Hmmm. This is fishy. I wonder if there is a leak somewhere in the new code.
Can you try something for me? Add a reader->GetOutput()->DebugOn() right
after SetInputData() and re-run. Do you see the object reference count go
to 0 in deactivate?

-berk


On Mon, Apr 28, 2014 at 11:53 AM, Maarten Beek <beekmaarten at yahoo.com>wrote:

> Hi all,
>
> I bumped into something I don't really understand:
>
> void MyClass::activate()
> {
>     vtkSmartPointer<vtkTIFFReader> reader =
> vtkSmartPointer<vtkTIFFReader>::New();
>     <...>
>     reader->Update();
>
>     m_Processor->SetInputData(reader->GetOutput());
> }
>
> void MyClass::deactivate()
> {
>     if( 0 != m_Processor )
>     {
>         m_Processor->RemoveAllInputs();
>         m_Processor->Delete();
>         m_Processor = 0;
>     }
> }
>
> In the deactivate() function I do need the RemoveAllInputs() call to avoid
> a 50MB memory leak (100 slice 512x512 tiff). I don't need RemoveAllInputs()
> when I use SetInputConnection(reader->GetOutputPort()) in the activate()
> function.
>
> Why is the difference between SetInputData() and SetInputConnection() with
> regards to memory management?
>
> m_Processor is derived from vtkImageAlgorithm and has an internal pipeline
> inside the RequestData(), processing the image data with vtkImageConvolve,
> vtkImageSobel2D, vtkImageThreshold and a few more.
>
> int ProcessorClass::RequestData(vtkInformation*, vtkInformationVector**,
> vtkInformationVector* outputVector)
> {
>     vtkInformation* outInfo = outputVector->GetInformationObject(0);
>     vtkImageData* output =
> vtkImageData::SafeDownCast(outInfo->Get(vtkdataObject::DATA_OBJECT()));
>
>     if( this->GetMTime() > this->BuildTime )
>     {
>         this->buildPipeline();
>     }
>
>     if( 0 != this->GetNumberOfInputConnections(0) )
>     {
>         this->MergeFilter->Update();
>         output->ShallowCopy(this->MergeFilter->GetOutput());
>     }
>
>     return 1;
> }
>
>
> Maarten
>
> _______________________________________________
> 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
>
> Follow this link to subscribe/unsubscribe:
> http://www.vtk.org/mailman/listinfo/vtkusers
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20140429/29a427d8/attachment.html>


More information about the vtkusers mailing list