[vtkusers] Re: about memory leak due to vtkPolyData::update() and vtkPolyData::GetPointCells();

Goodwin Lawlor goodwin.lawlor at ucd.ie
Tue Mar 27 11:19:29 EDT 2007


M.Salman at surrey.ac.uk wrote:
> Hello All,
> 
> I have serious memory leak problems in my code due to 
> vtkPolyData::Update() and vtkPolyData::GetPointCells(); so much serious  
> that the memory goes to 2 GB and then the program crashes down. After 
> perusing through various posts on the mailing list about memory leaks, I 
> understand that VTK is free from memory leaks and it has been tested 
> against purify.But,I do get memory leak problems. I have tested my code 
> against visual leak detector which gives following diagnosis :
> 
> 
> Leak Caused by : vtkPolyData::GetCellPoints()
> 
> WARNING: Visual Leak Detector detected memory leaks!
<snip>
> 
> I guess I am making some very basic and serious mistake in using 
> update() and getpointcells().Could anybody point out the problem and (if 
> possible) the solution to it ?

Hi ,

When you call GetPointCells() additional data structures Cells and Links 
are created to allow random access to cells and upward links from points 
to cells... they are registered by your vtkPolyData object so should be 
freed when the vtkPolyData object is freed up. Maybe they aren't, for 
some reason (calling Update()??).

Try to free them explicitly with:

vtkPolyData::DeleteCells()

perhaps after an Update call and before the next GetPointCells call

hth

Goodwin




More information about the vtkusers mailing list