quickly looking<div><br></div><div>you would have to call delete on contourActor </div><div><br></div><div>as when you do AddActor that will also increment the ref count. </div><div><br></div><div>Use vtkSmartPointer. </div>
<div><br></div><div> <br><br><div class="gmail_quote">On Wed, Jul 7, 2010 at 9:58 AM, Rakesh Patil <span dir="ltr">&lt;<a href="mailto:rakeshthp@in.com">rakeshthp@in.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<span style="font-family:Arial;color:rgb(51, 51, 51)">Hello,<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px"><br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
I have this particular function to display contours.. When i iterate this through a loop, for different timestep,</span><div><span style="font-family:Arial;color:rgb(51, 51, 51)">each time, i set new set of scalars for unstructuredGrid (uGrid) through the means of bathyArray.</span></div>
<div><span style="font-family:Arial;color:rgb(51, 51, 51)">I get the desired output as i need, but i see that there exists some memory leak.. at each iteration, some amount</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">of memory is being held.. I dont know by whom and where.. Below is the code<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">myClass<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
{<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">   ...<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
   vtkActor2D *element
 NumberActor;<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">   ...<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
public:<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">   ... // Constructors and destructors<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">   void DisplayContour();<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
   ...<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">};<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">Now, i have the function body as follows:<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">void myClass::DisplayConto
 ur()<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">{</span><div><span style="font-family:Arial;color:rgb(51, 51, 51)"><br>
</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">   uGrid-&gt;GetPointData()-&gt;SetScalars( bathyArray);</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">   uGrid-&gt;Update();</span></div>
<div><span style="font-family:Arial;color:rgb(51, 51, 51)"><br></span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">   vtkGeometryFilter *gf = vtkGeometryFilter::New();</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">   gf-&gt;SetInput( uGrid );<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">vtkThreshold *thr = vtkThreshold::New();<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
thr-&gt;SetInputConnection( gf-&gt;GetOutputPort() );<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">thr-&gt;ThresholdByUpper( BAD_VALUE );</span></div>
<div><span style="font-family:Arial;color:rgb(51, 51, 51)">thr-&gt;Update();</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)"><br></span></div><div><s style="font-family:Arial;color:rgb(51, 51, 51)">vtkContourGrid *contGrid = vtkContourGrid::New();</s></div>
<div><span style="font-family:Arial;color:rgb(51, 51, 51)">contGrid-&gt;SetInputConnection( thr-&gt;GetOutputPort());</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">contGrid-&gt;GenerateValues(n, dataRange);<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">vtkDataSetMapper *ldm = vtkDataSetMapper::New();<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
ldm-&gt;Set
 InputConnection( contGrid-&gt;GetOutputPort() );<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">ldm-&gt;SetScalarRange( dataRange);</span></div>
<div><span style="font-family:Arial;color:rgb(51, 51, 51)"><br></span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">pRenderer-&gt;RemoveActor(contourActor);</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)"><br>
</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">if(contourActor)</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">{</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">  contourActor-&gt;Delete();</span></div>
<div><span style="font-family:Arial;color:rgb(51, 51, 51)">  contourActor = NULL;</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">}<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">contourActor = vtkActor::New();</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">contourActor-&gt;SetMapper(ldm);</span></div>
<div><span style="font-family:Arial;color:rgb(51, 51, 51)">pRenderer-&gt;AddActor( contourActor );</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)"><br></span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">gf-&gt;Delete();<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
thr-&gt;Delete();</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">contGrid-&gt;Delete();</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">ldm-&gt;Delete();<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">}<br style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;margin-top:0px;margin-right:0px;margin-bottom:0px;margin-left:0px">
</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)"><br></span></div></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)"><br></span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">Can anyone help me or give some clue as what is the mistake i have been doing..?? What can i do to avoid this memory leaks.,?</span></div>
<div><span style="font-family:Arial;color:rgb(51, 51, 51)"><br></span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">Thanks in advance</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)"><br>
</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">Regards</span></div><div><span style="font-family:Arial;color:rgb(51, 51, 51)">Rakesh P
 atil</span></div><br><br><div style="border-top:1px dashed #ccc;border-bottom:1px dashed #ccc;padding:5px"><a href="http://mail.in.com/mails/new_reg.php?utm_source=invite&amp;utm_medium=outgoing" style="font:13px arial;color:#1E56A1;text-decoration:none" target="_blank">Dear <b>vtkusers !</b> Get Yourself a cool, short <b>@in.com</b> Email ID now!</a></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><br clear="all"><br>-- <br>| Aashish Chaudhary <br>| R&amp;D Engineer         <br>| Kitware Inc.            <br>| <a href="http://www.kitware.com">www.kitware.com</a>    <br>
</div>