<div dir="ltr"><div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">Try to add<br></span><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">SetSource(NULL);<br>
</span></span></span></div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">calls after you register polydata<br>
</span></span></span></div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><br>
</span></span>polydata-&gt;Register(NULL);<br></span><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">polydata</span><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">-&gt;SetSource(NULL);</span></span><br>
.....<br><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">output-&gt;Register(NULL);<br></span><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">output-&gt;SetSource(NULL);<br>
<br></span></span></div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">Another source of extra memory usage may be memory granularity,<br>
</span></span></div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">If you say that DeepCopy helps it means deleting/allocationg memory at the same and bugger chunks helps to avoid granularity.<br>
</span></span></div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">In this case nothing you can do.<br>
<br><br></span></span><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">In any case I would suggest to get <br>
<br></span></span><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>vtkTransformPolyDataFilter * trFilter = vtkTransformPolyDataFilter::New();<br>
<br></span></span></span></div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">and<br>
</span></span></span><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap"></span>   trFilter-&gt;Delete();</span><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"></span></span></div>
<div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">out of loop.<br>
</span></span></div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><br>
<br></span></span></div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">Regards,<br>
</span></span></div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    Alex<br>
</span></span></div><div><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><br>
</span></span></div></div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Jul 4, 2013 at 12:33 AM, Malsoaz James <span dir="ltr">&lt;<a href="mailto:jmalsoaz@yahoo.fr" target="_blank">jmalsoaz@yahoo.fr</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div style="font-size:10pt;font-family:Courier New,courier,monaco,monospace,sans-serif"><div style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:10pt">
Hi,</div><div style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:10pt"><br></div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif">
I&#39;m experiencing troubles when copying pointers of VTK object.</div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif"><br>
</div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif">Let&#39;s say I want to apply
 transformation to a polydata recursively like this:</div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif"><br></div><div style="font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif">
<span style="font-style:italic">    //Read STL</span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    vtkSTLReader * reader = vtkSTLReader::New();</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    reader-&gt;SetFileName(&quot;1.stl&quot;);</span></div><div style="background-color:transparent">
<span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    reader-&gt;Update();</span></div><div style="background-color:transparent"><span style="font-style:italic"><br>
</span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    vtkPolyData * polydata = reader-&gt;GetOutput();</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    polydata-&gt;Register(NULL);</span></div><div style="background-color:transparent">
<span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    reader-&gt;Delete();</span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><br>
</span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    vtkTransform * tr = vtkTransform::New();</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    tr-&gt;Translate(5, 10, 1);</span></div><div style="background-color:transparent">
<span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    tr-&gt;Update();</span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><br>
</span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    for(int i = 0 ; i &lt; 1000 ; ++i)</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    {</span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    <span style="white-space:pre-wrap">        </span>std::cout &lt;&lt; i &lt;&lt; std::endl;</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    <span style="white-space:pre-wrap">
        </span>vtkTransformPolyDataFilter * trFilter = vtkTransformPolyDataFilter::New();</span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>trFilter-&gt;SetInput(polydata);</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>trFilter-&gt;SetTransform(tr);</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>trFilter-&gt;Update();</span></div>
<div style="background-color:transparent"><span><br></span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>vtkPolyData * output = trFilter-&gt;GetOutput();</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>output-&gt;Register(NULL);</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>trFilter-&gt;Delete();</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><br></span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>polydata-&gt;Delete();</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>polydata = output;</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    }</span></div><div style="background-color:transparent"><span style="font-style:italic"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;background-color:transparent">    tr-&gt;Delete();</span><br>
</span></div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic">    polydata-&gt;Delete();</span></div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif">
<span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px"><br></span></div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif">
This is working fine and I have no VTK leaks. Unfortunately, I&#39;m noticing that memory for my program increases instead of remaining constant.</div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif">
What&#39;s wrong with theses few lines?</div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif"><br></div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif">
By the way, using DeepCopy to save output data is working:</div><div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px"><span style="white-space:pre-wrap">        </span><span style="font-style:italic">polydata = vtkPolyData::New();</span></span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>polydata-&gt;DeepCopy(output);</span></div>
<div style="background-color:transparent"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px;font-style:italic"><span style="white-space:pre-wrap">        </span>output-&gt;Delete();</span></div>
<div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif"><span style="font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif;font-size:13px">But I would like to avoid to deep copy data when I only need to add a reference to the pointer. I also would like to avoid the use of vtkSmartPointer.</span></div>
<div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif"><br></div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif">
Thank you for your help</div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif">Best.</div><div style="font-style:normal;font-size:13px;background-color:transparent;font-family:&#39;Courier New&#39;,courier,monaco,monospace,sans-serif">
<br></div></div></div><br>_______________________________________________<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/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_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/listinfo/vtkusers</a><br>
<br></blockquote></div><br></div>