<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> <BR>> Date: Fri, 25 Jun 2010 07:55:03 -0400<BR>> From: bill.lorensen@gmail.com<BR>> To: rakeshthp@in.com<BR>> CC: vtkusers@vtk.org<BR>> Subject: Re: [vtkusers] What exactly happens in this scenario?<BR>> <BR>> Yes, it will leak.<BR>> <BR>> To prevent the leak,, in your constructor,<BR>> elementNumberActor = NULL;<BR>> <BR>> In DisplayElementNumbers() before assigning the actor,<BR>> if (elementNumberActor != NULL)<BR>> {<BR>> elementNumberActor->Delete();<BR>> }<BR>> <BR>> In the destuctor,<BR>> if (elementNumberActor != NULL)<BR>> {<BR>> elementNumberActor->Delete();<BR>> }<BR>> <BR>> <BR>> On Fri, Jun 25, 2010 at 7:43 AM, Rakesh Patil <rakeshthp@in.com> wrote:<BR>> > Hello,<BR>> ><BR>> > I want to know what exactly happens in this scenario. I have a C++ class<BR>> > say, "myClass"<BR>> ><BR>> > myClass<BR>> > {<BR>> > ...<BR>> > vtkActor2D *elementNumberActor;<BR>> > ...<BR>> > public:<BR>> > ... // Constructors and destructors<BR>> ><BR>> > void DisplayElementNumbers();<BR>> > ...<BR>> > };<BR>> ><BR>> > Now, i have the function body as follows:<BR>> ><BR>> > void myClass::DisplayElementNumbers()<BR>> > {<BR>> > vtkIdFilter *ids = vtkIdFilter::New();<BR>> > ids->SetInputConnection( programmableFilter-> GetOutputPort() );<BR>> > ids->CellIdsOn();<BR>> > ids->FieldDataOn();<BR>> ><BR>> > vtkCellCenters *cellC = vtkCellCenters::New();<BR>> > cellC->SetInputConnection( ids->GetOutputPort() );<BR>> ><BR>> > vtkSelecttVisiblePoints *vispts = vtkSelectVisiblePoints::New();<BR>> > vispts->SetInputConnection( cellC->GetOutputPort() );<BR>> > vispts->SetRenderer( pRenderer );<BR>> ><BR>> > vtkLabelDataMapper *ldm = vtkLabelDataMapper::New();<BR>> > ldm->SetInputConnection( vispts->GetOutput Port() );<BR>> > ldm->SetLabelModeToLabelFieldData();<BR>> ><BR>> > elementNumberActor = vtkActor2D::New();<BR>> > elementNumberActor->SetMapper (ldm );<BR>> ><BR>> > ldm->Delete();<BR>> > vispts->Delete();<BR>> > cellC->Delete();<BR>> > ids->Delete();<BR>> ><BR>> > }<BR>> ><BR>> > Well, the statement in the box is<BR>> ><BR>> > elementNumberActor = vtkActor2D::New();<BR>> ><BR>> > If i call this function again and again, will this statement cause in memory<BR>> > leak ??<BR>> > How and what will be the performance of my application??<BR>> ><BR>> > Thanks in advance<BR>> ><BR>> > Regards<BR>> > Rakesh Patil<BR>> ><BR>> ><BR>> > Dear VTK ! Get Yourself a cool, short @in.com Email ID now!<BR>> > _______________________________________________<BR>> > Powered by www.kitware.com<BR>> ><BR>> > Visit other Kitware open-source projects at<BR>> > http://www.kitware.com/opensource/opensource.html<BR>> ><BR>> > Please keep messages on-topic and check the VTK FAQ at:<BR>> > http://www.vtk.org/Wiki/VTK_FAQ<BR>> ><BR>> > Follow this link to subscribe/unsubscribe:<BR>> > http://www.vtk.org/mailman/listinfo/vtkusers<BR>> ><BR>> ><BR>> _______________________________________________<BR>> Powered by www.kitware.com<BR>> <BR>> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html<BR>> <BR>> Please keep messages on-topic and check the VTK FAQ at: http://www.vtk.org/Wiki/VTK_FAQ<BR>> <BR>> Follow this link to subscribe/unsubscribe:<BR>> 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>