<html><body><div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">Using SetInputData(input); and not implementing ReportReferences seems to work.<br><br>Thanks Berk!<br style="" class=""><div style="" class=""><span style="" class=""><br style=""></span></div><div style="display: block;" class="yahoo_quoted"> <div class="" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt"> <div class="" style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 12pt"> <div style="" class="" dir="ltr"> <font style="" class="" face="Arial" size="2"> On Wednesday, April 30, 2014 4:47:05 PM, Maarten Beek <beekmaarten@yahoo.com> wrote:<br style="" class=""> </font> </div> <div style="" class=""><div style="" class="" id="yiv1227140051"><div style="" class=""><div
class="" style="color:#000;background-color:#fff;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">When I was using the code I commented out in ReportReferences, this->ImageConvolve wasn't deleted in the destructor because its value was set to NULL.<br style="" class="" clear="none">So that didn't work either...<br style="" class="" clear="none"><br style="" class="" clear="none">Maarten<br style="" class="" clear="none"><div style="" class=""><span style="" class=""><br style="" class="" clear="none"></span></div><div style="" class="" id="yiv1227140051yqt00063"><div class="" style="display:block"> <div class="" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"> <div class="" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"> <div style="" class="" dir="ltr"> <font style=""
class="" face="Arial" size="2"> On Wednesday, April 30, 2014 4:03:42 PM, Berk Geveci <berk.geveci@kitware.com> wrote:<br style="" class="" clear="none"> </font> </div> <div style="" class=""><div style="" class="" id="yiv1227140051"><div style="" class=""><div style="" class="" dir="ltr">Don't use this:<div style="" class=""><br style="" class="" clear="none"></div><div style="" class="">this->ImageConvolve->SetInputConnection(this->GetInputConnection(0, 0));<br style="" class="" clear="none"></div><div style="" class=""><br style="" class="" clear="none"></div><div style="" class="">Use this instead:</div><div style="" class=""><br style="" class="" clear="none"></div><div style="" class="">this->ImageConvolve->SetInputData(input); <br style="" class="" clear="none">
</div><div style="" class=""><br style="" class="" clear="none"></div><div style="" class="">This needs to be done in RequestData every time it executes btw. Input can change. I didn't check if there are other filters that need to do this. Overall, internal filters should not share the input connection of the outer filter unless you are fairly knowledgeable in how pipelines deal with references.</div>
<div style="" class=""><br style="" class="" clear="none"></div><div style="" class="">PS: By using SetInputConnection(), you are creating a reference loop that would require that right reporting in ReportReferences. I'd think that the code that you commented out would work but I would have to dig to be sure. This reference loop is most probably the cause of the leak you are seeing.</div>
<div style="" class=""><br style="" class="" clear="none"></div><div style="" class="">-berk</div></div><div style="" class="" id="yiv1227140051yqt89522"><div style="" class=""><br style="" class="" clear="none"><br style="" class="" clear="none"><div style="" class="">On Wed, Apr 30, 2014 at 2:20 PM, Maarten Beek <span style="" class="" dir="ltr"><<a style="" class="" rel="nofollow" shape="rect" ymailto="mailto:beekmaarten@yahoo.com" target="_blank" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>></span> wrote:<br style="" class="" clear="none">
<blockquote class="" style="margin:0 0 0 .8ex"><div style="" class=""><div class="" style="font-size:12pt;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">I believe that that is what I am doing; I have attached the cpp file for you to have a look at.<br style="" class="" clear="none">
<br style="" class="" clear="none">Thank you for your help - Maarten<div style="" class=""><div style="" class=""><br style="" class="" clear="none"><div style="" class=""><span style="" class=""><br style="" class="" clear="none"></span></div><div class="" style="display:block"> <div class="" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">
<div class="" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"> <div style="" class="" dir="ltr"> <font style="" class="" face="Arial"> On Wednesday, April 30, 2014 1:05:15 PM, Berk Geveci <<a style="" class="" rel="nofollow" shape="rect" ymailto="mailto:berk.geveci@kitware.com" target="_blank" href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>> wrote:<br style="" class="" clear="none">
</font> </div> <div style="" class=""><div style="" class=""><div style="" class=""><div style="" class="" dir="ltr">vtkImageOpenClose3D may be too complicated for what you are trying to achieve. Can you describe your algorithm a bit?
In most cases, you can simply instantiate bunch of algorithms in RequestData(), set the input using the input data to the outer filter and using SetInputData() and then shallow copying the output of the last filter to the output of the outer filter.</div>
<div style="" class=""><div style="" class=""><br style="" class="" clear="none"><br style="" class="" clear="none"><div style="" class="">On Wed, Apr 30, 2014 at 12:00 PM, Maarten Beek <span style="" class="" dir="ltr"><<a style="" class="" rel="nofollow" shape="rect" ymailto="mailto:beekmaarten@yahoo.com" target="_blank" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>></span> wrote:<br style="" class="" clear="none">
<blockquote class="" style="margin:0 0 0 .8ex"><div style="" class=""><div class="" style="font-size:12pt;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><div style="" class="">
<span style="" class="">I replaced my </span><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">ProcessorClass by vtkImageThreshold and the strange behaviour disappeared.</span></span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<br style="" class="" clear="none"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""></span></span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">I guess my </span></span></span></span><span style="" class=""></span><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">ProcessorClass is wrong.... :-(</span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">So my question now is: how to correctly write a vtkImageAlgorithm that has an internal pipeline?</span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">I have looked at vtkImageOpenClose3D, but (apparently!) don't really understand SetSharedInputInformation(), SetSharedOutputInformation(), and ReportReferences().</span></span></span></span></div>
<span style="" class=""><font style="" class="" color="#888888"></font></span><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">Maarten<br style="" class="" clear="none"></span></span></span></span></div>
<div style="" class=""><div style="" class=""><div class="" style="display:block"> <div class="" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"> <div class="" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">
<div style="" class="" dir="ltr"> <font style="" class="" face="Arial"> On Wednesday, April 30, 2014 11:37:23 AM, Berk Geveci <<a style="" class="" rel="nofollow" shape="rect" ymailto="mailto:berk.geveci@kitware.com" target="_blank" href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>> wrote:<br style="" class="" clear="none">
</font> </div> <div style="" class=""><div style="" class="">
<div style="" class=""><div style="" class="" dir="ltr"><div style="" class="">Confusing.</div><div style="" class=""><br style="" class="" clear="none"></div><div style="" class="">Can you compile VTK with VTK_DEBUG_LEAKS set to ON (it is an advanced CMake flag) and see if you get reports of any objects leaking at exit?</div>
<div style="" class="">
<br style="" class="" clear="none"></div></div>
<div style="" class=""><div style="" class=""><br style="" class="" clear="none"><br style="" class="" clear="none"><div style="" class="">On Tue, Apr 29, 2014 at 4:40 PM, Maarten Beek <span style="" class="" dir="ltr"><<a style="" class="" rel="nofollow" shape="rect" ymailto="mailto:beekmaarten@yahoo.com" target="_blank" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>></span> wrote:<br style="" class="" clear="none">
<blockquote class="" style="margin:0 0 0 .8ex"><div style="" class=""><div class="" style="font-size:12pt;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><div style="" class="">
<span style="" class="">Some additional info I found:</span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none">
<span style="" class=""></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class="">When I use SetInputConnection(), I see only one object being destructed as well (like with using SetInputData w/o RemoveAllInputs()).</span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class="">However the memory usage with SetInputConnection() is 378Mb as opposed to 430Mb with SetInputData(): the difference is about 50Mb (the size of the tiff image).</span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"><span style="" class=""></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<span style="" class="">As I said in the earlier email I sent today, I am loading 2 images into 2 different </span><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">ProcessorClass
objects, or at least that's what I think. The images are similar and come from the same file, but the reader (which is destroyed by vtkSmartPointer when it gets out of scope?) cannot be that smart to realize it can tell the </span></span></span></span><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">ProcessorClass objects to share the image, can it?</span></span></span></span></div>
<span style="" class=""><font style="" class="" color="#888888"></font></span><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">Maarten<br style="" class="" clear="none"></span></span></span></span></div>
<div style="" class=""><div style="" class=""><div class="" style="display:block"> <div class="" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"> <div class="" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">
<div style="" class="" dir="ltr"> <font style="" class="" face="Arial"> On , Maarten Beek <<a style="" class="" rel="nofollow" shape="rect" ymailto="mailto:beekmaarten@yahoo.com" target="_blank" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>> wrote:<br style="" class="" clear="none"> </font> </div> <div style="" class=""><div style="" class="">
<div style="" class=""><div class="" style="font-size:12pt;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
I see (only reporting lines with reference to ReferenceCount):<br style="" class="" clear="none"><br style="" class="" clear="none">-> activate()<br style="" class="" clear="none">vtkImageData (00000000070808D0):UnRegistered by vtkInformation(...), ReferenceCount = 3<br style="" class="" clear="none">
<br style="" class="" clear="none">vtkImageData (00000000070ADA70):UnRegistered by vtkInformation(...), ReferenceCount = 3<br style="" class="" clear="none"><br style="" class="" clear="none">->deactivate() (without RemoveAllInputs() call)<br style="" class="" clear="none">vtkImageData (00000000070ADA70):UnRegistered by vtkTrivialProducer (...), ReferenceCount = 2<br style="" class="" clear="none">
<br style="" class="" clear="none">vtkImageData (00000000070ADA70):UnRegistered by vtkInformation (...), ReferenceCount = 1<br style="" class="" clear="none"><br style="" class="" clear="none">vtkImageData (00000000070ADA70):Registered by
vtkTrivialProducer (...), ReferenceCount = 2<br style="" class="" clear="none"><br style="" class="" clear="none">vtkImageData (00000000070ADA70):UnRegistered by vtkGarbageCollectorImpl (...), ReferenceCount = 0<br style="" class="" clear="none"><div style="" class=""><br style="" class="" clear="none"><span style="" class=""></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">vtkObject (00000000070ADA70): Destructing!</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
-> activate()<br style="" class="" clear="none">vtkImageData (0000000006FA15D0):UnRegistered by vtkInformation(...), ReferenceCount = 3<br style="" class="" clear="none"><br style="" class="" clear="none">vtkImageData (0000000006FB0180):UnRegistered by vtkInformation(...), ReferenceCount = 3</div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
->deactivate() (with RemoveAllInputs() call)<br style="" class="" clear="none">vtkImageData (0000000006FA15D0):UnRegistered by vtkTrivialProducer (...), ReferenceCount = 2<br style="" class="" clear="none"><br style="" class="" clear="none">vtkImageData (0000000006FA15D0):UnRegistered by vtkInformation (...), ReferenceCount = 1<br style="" class="" clear="none">
<br style="" class="" clear="none">vtkImageData (0000000006FA15D0):Registered by vtkGarbageCollectorImpl (...), ReferenceCount = 2</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">vtkImageData (0000000006FA15D0):UnRegistered by vtkGarbageCollectorImpl (...), ReferenceCount = 0</div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
vtkObject (0000000006FA15D0): Destructing!</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none">
</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">vtkImageData (0000000006FB0180):UnRegistered by vtkTrivialProducer (...), ReferenceCount = 2<br style="" class="" clear="none">
<br style="" class="" clear="none">vtkImageData
(0000000006FB0180):UnRegistered by vtkInformation (...), ReferenceCount = 1<br style="" class="" clear="none"><br style="" class="" clear="none">vtkImageData (0000000006FB0180):Registered by vtkGarbageCollectorImpl (...), ReferenceCount = 2</div><div style="" class=""><br style="" class="" clear="none">
</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">vtkImageData (0000000006FB0180):UnRegistered by vtkGarbageCollectorImpl (...), ReferenceCount = 0</div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
vtkObject (0000000006FB0180): Destructing!</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none">
<span style="" class=""></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
It makes sense in my code that I create 2 copies of vtkImageData, loaded into different <span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">ProcessorClass objects, but I don't understand
why the first copy doesn't get destructed when I am not using </span></span></span></span><br style="" class="" clear="none">RemoveAllInputs()</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">Maarten<br style="" class="" clear="none"></div><div style="" class=""><div class="" style="display:block">
<div class="" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt"> <div class="" style="font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif;font-size:12pt">
<div style="" class="" dir="ltr"> <font style="" class="" face="Arial"> On Tuesday, April 29, 2014
10:39:24 AM, Berk Geveci <<a style="" class="" rel="nofollow" shape="rect" ymailto="mailto:berk.geveci@kitware.com" target="_blank" href="mailto:berk.geveci@kitware.com">berk.geveci@kitware.com</a>> wrote:<br style="" class="" clear="none"> </font> </div> <div style="" class=""><div style="" class=""><div style="" class=""><div style="" class="" dir="ltr">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?<div style="" class="">
<br style="" class="" clear="none"></div><div style="" class="">-berk</div></div><div style="" class=""><br style="" class="" clear="none"><br style="" class="" clear="none"><div style="" class="">On Mon, Apr 28, 2014 at 11:53 AM, Maarten Beek <span style="" class="" dir="ltr"><<a style="" class="" rel="nofollow" shape="rect" ymailto="mailto:beekmaarten@yahoo.com" target="_blank" href="mailto:beekmaarten@yahoo.com">beekmaarten@yahoo.com</a>></span> wrote:<br style="" class="" clear="none">
<blockquote class="" style="margin:0 0 0 .8ex"><div style="" class=""><div style="" class=""><div class="" style="font-size:12pt;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><div style="" class="">
Hi all,</div><div style="" class=""><br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">I bumped into something I don't really understand:<br style="" class="" clear="none">
</div><div style="" class=""><br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">void MyClass::activate()</div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
{</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""> vtkSmartPointer<vtkTIFFReader> reader = vtkSmartPointer<vtkTIFFReader>::New();</span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""> <...></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<span style="" class=""><span style="" class=""><span style="" class="">
reader->Update();</span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><br style="" class="" clear="none">
</span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""> m_Processor->SetInputData(reader->GetOutput());</span><br style="" class="" clear="none">
}</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
void MyClass::deactivate()</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">{</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<span style="" class=""> if( 0 != m_Processor )</span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""> {</span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""> <span style="" class=""> m_Processor->RemoveAllInputs();</span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> <span style="" class=""> m_Processor->Delete();</span></span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> <span style="" class=""> m_Processor = 0;<br style="" class="" clear="none">
</span></span></span></span></span></span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""> }</span></span></span><br style="" class="" clear="none">
}</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
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.</div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
Why is the difference between SetInputData() and SetInputConnection() with regards to memory management?</div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<br style="" class="" clear="none"></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">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.</span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">int ProcessorClass::RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector* outputVector)</span></span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">{</span></span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> vtkInformation* outInfo = outputVector->GetInformationObject(0);</span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> vtkImageData* output = vtkImageData::SafeDownCast(outInfo->Get(vtkdataObject::DATA_OBJECT()));</span></span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><br style="" class="" clear="none"></span></span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> if( this->GetMTime() > this->BuildTime )</span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">
</span>{</span></span></span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> <span style="" class=""> this->buildPipeline();</span></span></span></span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> </span></span>}</span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><br style="" class="" clear="none"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""></span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> if( 0 != this->GetNumberOfInputConnections(0) )</span></span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> {</span></span></span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> <span style="" class=""> this->MergeFilter->Update();</span></span></span></span></span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> <span style="" class=""> output->ShallowCopy(this->MergeFilter->GetOutput());</span></span></span></span></span></span></span></span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">
}</span></span></span></span></span></span></span></span></span></span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<br style="" class="" clear="none"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""></span></span></span></span></span></span></span></span></span></span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""> return 1;</span></span></span></span></span></span></span></span></span></span></span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">
<span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class="">}<span style="" class=""><font style="" class="" color="#888888"><br style="" class="" clear="none"></font></span></span></span></span></span></span></span></span></span></span></span></span></span></span></div>
<span style="" class=""><font style="" class="" color="#888888"></font></span><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><br style="" class="" clear="none">
</span></span></span></span></div><div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif"><span style="" class=""><span style="" class=""><span style="" class=""><span style="" class=""><br style="" class="" clear="none">
</span></span></span></span></div>
<div class="" style="font-style:normal;font-size:16px;background-color:transparent;font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif">Maarten<br style="" class="" clear="none"></div></div></div></div><br style="" class="" clear="none">
_______________________________________________<br style="" class="" clear="none">
Powered by <a style="" class="" rel="nofollow" shape="rect" target="_blank" href="http://www.kitware.com/">www.kitware.com</a><br style="" class="" clear="none">
<br style="" class="" clear="none">
Visit other Kitware open-source projects at <a style="" class="" rel="nofollow" shape="rect" target="_blank" href="http://www.kitware.com/opensource/opensource.html">http://www.kitware.com/opensource/opensource.html</a><br style="" class="" clear="none">
<br style="" class="" clear="none">
Please keep messages on-topic and check the VTK FAQ at: <a style="" class="" rel="nofollow" shape="rect" target="_blank" href="http://www.vtk.org/Wiki/VTK_FAQ">http://www.vtk.org/Wiki/VTK_FAQ</a><br style="" class="" clear="none">
<br style="" class="" clear="none">
Follow this link to subscribe/unsubscribe:<br style="" class="" clear="none">
<a style="" class="" rel="nofollow" shape="rect" target="_blank" href="http://www.vtk.org/mailman/listinfo/vtkusers">http://www.vtk.org/mailman/listinfo/vtkusers</a><br style="" class="" clear="none">
<br style="" class="" clear="none"></blockquote></div><br style="" class="" clear="none"></div></div></div><br style="" class="" clear="none"><br style="" class="" clear="none"></div> </div> </div> </div></div> </div></div></div><br style="" class="" clear="none"><br style="" class="" clear="none"></div> </div> </div> </div>
</div></div></div></div>
</blockquote></div><br style="" class="" clear="none"></div></div></div></div><br style="" class="" clear="none"><br style="" class="" clear="none"></div> </div> </div> </div> </div></div></div></div></blockquote></div><br style="" class="" clear="none"></div></div></div></div><br style="" class="" clear="none"><br style="" class="" clear="none"></div>
</div> </div> </div> </div></div></div></div></blockquote></div><br style="" class="" clear="none"></div></div></div></div><br style="" class="" clear="none"><br style="" class="" clear="none"></div> </div> </div> </div></div> </div></div></div><br style="" class=""><br style="" class=""></div> </div> </div> </div> </div></body></html>