<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Or to use smart pointer, at least for vtkActor2D<BR><BR>x.z.<BR><BR><BR>&nbsp;<BR>&gt; Date: Fri, 25 Jun 2010 07:55:03 -0400<BR>&gt; From: bill.lorensen@gmail.com<BR>&gt; To: rakeshthp@in.com<BR>&gt; CC: vtkusers@vtk.org<BR>&gt; Subject: Re: [vtkusers] What exactly happens in this scenario?<BR>&gt; <BR>&gt; Yes, it will leak.<BR>&gt; <BR>&gt; To prevent the leak,, in your constructor,<BR>&gt; elementNumberActor = NULL;<BR>&gt; <BR>&gt; In DisplayElementNumbers() before assigning the actor,<BR>&gt; if (elementNumberActor != NULL)<BR>&gt; {<BR>&gt; elementNumberActor-&gt;Delete();<BR>&gt; }<BR>&gt; <BR>&gt; In the destuctor,<BR>&gt; if (elementNumberActor != NULL)<BR>&gt; {<BR>&gt; elementNumberActor-&gt;Delete();<BR>&gt; }<BR>&gt; <BR>&gt; <BR>&gt; On Fri, Jun 25, 2010 at 7:43 AM, Rakesh Patil &lt;rakeshthp@in.com&gt; wrote:<BR>&gt; &gt; Hello,<BR>&gt; &gt;<BR>&gt; &gt; I want to know what exactly happens in this scenario. I have a C++ class<BR>&gt; &gt; say, "myClass"<BR>&gt; &gt;<BR>&gt; &gt; myClass<BR>&gt; &gt; {<BR>&gt; &gt; ...<BR>&gt; &gt; vtkActor2D *elementNumberActor;<BR>&gt; &gt; ...<BR>&gt; &gt; public:<BR>&gt; &gt; ... // Constructors and destructors<BR>&gt; &gt;<BR>&gt; &gt; void DisplayElementNumbers();<BR>&gt; &gt; ...<BR>&gt; &gt; };<BR>&gt; &gt;<BR>&gt; &gt; Now, i have the function body as follows:<BR>&gt; &gt;<BR>&gt; &gt; void myClass::DisplayElementNumbers()<BR>&gt; &gt; {<BR>&gt; &gt; vtkIdFilter *ids = vtkIdFilter::New();<BR>&gt; &gt; ids-&gt;SetInputConnection( programmableFilter-&gt; GetOutputPort() );<BR>&gt; &gt; ids-&gt;CellIdsOn();<BR>&gt; &gt; ids-&gt;FieldDataOn();<BR>&gt; &gt;<BR>&gt; &gt; vtkCellCenters *cellC = vtkCellCenters::New();<BR>&gt; &gt; cellC-&gt;SetInputConnection( ids-&gt;GetOutputPort() );<BR>&gt; &gt;<BR>&gt; &gt; vtkSelecttVisiblePoints *vispts = vtkSelectVisiblePoints::New();<BR>&gt; &gt; vispts-&gt;SetInputConnection( cellC-&gt;GetOutputPort() );<BR>&gt; &gt; vispts-&gt;SetRenderer( pRenderer );<BR>&gt; &gt;<BR>&gt; &gt; vtkLabelDataMapper *ldm = vtkLabelDataMapper::New();<BR>&gt; &gt; ldm-&gt;SetInputConnection( vispts-&gt;GetOutput Port() );<BR>&gt; &gt; ldm-&gt;SetLabelModeToLabelFieldData();<BR>&gt; &gt;<BR>&gt; &gt; elementNumberActor = vtkActor2D::New();<BR>&gt; &gt; elementNumberActor-&gt;SetMapper (ldm );<BR>&gt; &gt;<BR>&gt; &gt; ldm-&gt;Delete();<BR>&gt; &gt; vispts-&gt;Delete();<BR>&gt; &gt; cellC-&gt;Delete();<BR>&gt; &gt; ids-&gt;Delete();<BR>&gt; &gt;<BR>&gt; &gt; }<BR>&gt; &gt;<BR>&gt; &gt; Well, the statement in the box is<BR>&gt; &gt;<BR>&gt; &gt; elementNumberActor = vtkActor2D::New();<BR>&gt; &gt;<BR>&gt; &gt; If i call this function again and again, will this statement cause in memory<BR>&gt; &gt; leak ??<BR>&gt; &gt; How and what will be the performance of my application??<BR>&gt; &gt;<BR>&gt; &gt; Thanks in advance<BR>&gt; &gt;<BR>&gt; &gt; Regards<BR>&gt; &gt; Rakesh Patil<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; Dear VTK ! Get Yourself a cool, short @in.com Email ID now!<BR>&gt; &gt; _______________________________________________<BR>&gt; &gt; Powered by www.kitware.com<BR>&gt; &gt;<BR>&gt; &gt; Visit other Kitware open-source projects at<BR>&gt; &gt; http://www.kitware.com/opensource/opensource.html<BR>&gt; &gt;<BR>&gt; &gt; Please keep messages on-topic and check the VTK FAQ at:<BR>&gt; &gt; http://www.vtk.org/Wiki/VTK_FAQ<BR>&gt; &gt;<BR>&gt; &gt; Follow this link to subscribe/unsubscribe:<BR>&gt; &gt; http://www.vtk.org/mailman/listinfo/vtkusers<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; _______________________________________________<BR>&gt; Powered by www.kitware.com<BR>&gt; <BR>&gt; Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<BR>&gt; <BR>&gt; Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<BR>&gt; <BR>&gt; Follow this link to subscribe/unsubscribe:<BR>&gt; http://www.vtk.org/mailman/listinfo/vtkusers<BR>                                               <br /><hr />The New Busy is not the old busy. Search, chat and e-mail from your inbox. <a href='http://www.windowslive.com/campaign/thenewbusy?ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_3' target='_new'>Get started.</a></body>
</html>