<div dir="ltr">Thanks for both!<br><br>Fixed it finally.<br><br>Jothy<br><br><div class="gmail_quote">On Tue, May 15, 2012 at 3:30 PM, Hal Canary <span dir="ltr">&lt;<a href="mailto:hal@cs.unc.edu" target="_blank">hal@cs.unc.edu</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 05/15/2012 10:19 AM, Jothybasu Selvaraj wrote:<br>
</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">
Hi all,<br>
<br>
I have a pipeline like this, every time I call this function the memory<br>
increases ~10MB. How can I fix this?<br>
<br>
I have a imgData already instantiated like this<br>
<br>
vtkSmartPointer&lt;vtkImageData&gt;<u></u>img=<br>
      vtkSmartPointer&lt;vtkImageData&gt;:<u></u>:New();<br>
<br>
vtkSmartPointer&lt;<u></u>vtkXMLImageReader&gt;rd=<br>
      vtkSmartPointer&lt;<u></u>vtkXMLImageReader&gt;::New();<br>
rd-&gt;SetFilename(&quot;filename&quot;);<br>
rd-&gt;Update();<br>
<br>
img=rd-&gt;GetOutput();<br>
<br>
<br>
//Now I repeat this function several times<br>
<br>
    vtkSmartPointer&lt;<u></u>vtkImageShiftScale&gt;scaler=<br>
            vtkSmartPointer&lt;<u></u>vtkImageShiftScale&gt;::New();<br></div>
    scaler-&gt;SetInput(img);*//is this correct way of doing?*<div class="im"><br>
<br>
    scaler-&gt;SetScale(0.5);//<u></u>Multiply<br>
    scaler-&gt;<u></u>SetOutputScalarTypeToDouble();<br>
<br>
    //scaler-&gt;ReleaseDataFlagOn();<u></u>//Tried with this too<br>
    scaler-&gt;Update();<br>
<br></div>
    img=scaler-&gt;GetOutput();*//is this correct way of doing?*<div class="im"><br>
<br>
I am beginner in C++, so I am expecting some silly mistakes.<br>
<br>
</div></blockquote>
<br>
Nine out of ten times , you want to do<br>
        b-&gt;SetInputConnection(a-&gt;<u></u>GetOutputPort());<br>
instead of<br>
        b-&gt;SetInput(a-&gt;GetOutput());<br>
<br>
See <a href="http://www.vtk.org/Wiki/VTK/FAQ" target="_blank">http://www.vtk.org/Wiki/VTK/<u></u>FAQ</a> .<br>
<br>
Is this what you want to do?<div class="im"><br>
<br>
vtkSmartPointer&lt;<u></u>vtkXMLImageReader&gt;rd=<br>
     vtkSmartPointer&lt;<u></u>vtkXMLImageReader&gt;::New();<br>
rd-&gt;SetFilename(&quot;filename&quot;);<br>
rd-&gt;Update();<br></div>
vtkAlgorithmOutput * outputPort = rd-&gt;GetOutputPort();<div class="im"><br>
<br>
//Now I repeat this function several times<br>
  {<br>
  vtkSmartPointer&lt;<u></u>vtkImageShiftScale&gt;scaler=<br>
          vtkSmartPointer&lt;<u></u>vtkImageShiftScale&gt;::New();<br></div>
  scaler-&gt;SetInputConnection(<u></u>outputPort);<div class="im"><br>
  scaler-&gt;SetScale(0.5);//<u></u>Multiply<br>
  scaler-&gt;<u></u>SetOutputScalarTypeToDouble();<br></div>
  scaler-&gt;Update();<br>
  outputPort = scaler-&gt;GetOutputPort();<br>
  }<br>
<br>
//then<br>
do_something_with(outputPort);<span class="HOEnZb"><font color="#888888"><br>
<br>
<br>
-- <br>
Hal Canary<br>
<a href="http://cs.unc.edu/%7Ehal/" target="_blank">http://cs.unc.edu/~hal/</a><br>
______________________________<u></u>_________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/<u></u>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" target="_blank">http://www.vtk.org/Wiki/VTK_<u></u>FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.vtk.org/mailman/listinfo/vtkusers" target="_blank">http://www.vtk.org/mailman/<u></u>listinfo/vtkusers</a><br>
</font></span></blockquote></div><br><br clear="all"><br>-- <br><div dir="ltr">Jothy<br></div><br>
</div>