[vtkusers] Re: Memory bug when cutting vtkPointSet/PolyData using vtkCutter?

Goodwin Lawlor goodwin.lawlor at ucd.ie
Thu May 11 06:29:55 EDT 2006


Julia Schnabel wrote:
> Hello,
> 
> I have been trying to find any info on this in the vk digest, but in vain.
> Maybe someone could point me to the probably *very* obvious thing that 
> I'm doing wrong.
> 
> When cutting a vtkPolyData repeatedly, the program will dramatically 
> increase in memory
> causing an "Abort". I'm using vtk 4.4.2, compiled with the 
> VTK_DEBUG_LEAKS check on,
> and I've also been using the DebugOn() methods, without gaining any more 
> insight.
> 
> Here is a snippet of code - when calling this method repeately, the 
> memory explodes
> (I've also been trying to declare plane and cutter as static):
> 
> Thank you for any hints!
> Julia
> 
> -- begin code snippet
> 
> void myViewer::DrawObject(vtkPolyData *points)
> {
>   if (points != NULL) {
> 
>     int i, j;
>     double point[3], bounds[6], origin[3], normal[3];
> 
>     // Allocate vtk classes
>     vtkPlane *plane   = vtkPlane::New();
>     vtkCutter *cutter = vtkCutter::New();
<snip>
>     }
> 
>     // Be good
>     plane->Delete();
>     cutter->Delete();
>   }
> }

Hi Julia,

Try

cout << "Plane ref count: " << plane->GetReferenceCount() << endl;
cout << "Cutter ref count: " << cutter->GetReferenceCount() << endl;

to make sure the count is only one before you call Delete()

Alternatively, use a smart pointer.

hth

Goodwin




More information about the vtkusers mailing list