[vtkusers] This code gives memory leak.. Why?

Rakesh Patil rakeshthp at in.com
Wed Jul 7 09:58:11 EDT 2010


Hello,I have this particular function to display contours.. When i iterate this through a loop, for different timestep,each time, i set new set of scalars for unstructuredGrid (uGrid) through the means of bathyArray.I get the desired output as i need, but i see that there exists some memory leak.. at each iteration, some amountof memory is being held.. I dont know by whom and where.. Below is the codemyClass{ ... vtkActor2D *elementNumberActor; ...public: ... // Constructors and destructors void DisplayContour(); ...};Now, i have the function body as follows:void myClass::DisplayContour(){ uGrid>GetPointData()>SetScalars( bathyArray); uGrid>Update(); vtkGeometryFilter *gf = vtkGeometryFilter::New(); gf>SetInput( uGrid );vtkThreshold *thr = vtkThreshold::New();thr>SetInputConnection( gf>GetOutputPort() );thr>ThresholdByUpper( BADVALUE );thr>Update();vtkContourGrid *contGrid = vtkContourGrid::New();contGrid>SetInputConnection( thr>GetOutputPort());contGrid>GenerateValues(n, dat
 aRange);vtkDataSetMapper *ldm = vtkDataSetMapper::New();ldm>SetInputConnection( contGrid>GetOutputPort() );ldm>SetScalarRange( dataRange);pRenderer>RemoveActor(contourActor);if(contourActor){contourActor>Delete();contourActor = NULL;}contourActor = vtkActor::New();contourActor>SetMapper(ldm);pRenderer>AddActor( contourActor );gf>Delete();thr>Delete();contGrid>Delete();ldm>Delete();}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.,?Thanks in advanceRegardsRakesh PatilDear vtkusers ! Get Yourself a cool, short @in.com Email ID now!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20100707/b8d0d761/attachment.htm>


More information about the vtkusers mailing list