<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7638.1">
<TITLE>about memory leak due to  vtkPolyData::update() and vtkPolyData::GetPointCells(); </TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>Hello All,<BR>
<BR>
I have serious memory leak problems in my code due to vtkPolyData::Update() and vtkPolyData::GetPointCells(); so much serious&nbsp; 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 :<BR>
<BR>
<BR>
Leak Caused by : vtkPolyData::GetCellPoints()<BR>
<BR>
WARNING: Visual Leak Detector detected memory leaks!<BR>
---------- Block 48179 at 0x013A81E0: 4 bytes ----------<BR>
&nbsp; Call Stack:<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkCellLinks.cxx (68): vtkCellLinks::AllocateLinks<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkCellLinks.cxx (152): vtkCellLinks::BuildLinks<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkPolyData.cxx (993): vtkPolyData::BuildLinks<BR>
&nbsp;&nbsp;&nbsp; C:\vtkProjects\main\code\coreEmbed.cpp (158): coreEmbed::recalcNormals -------------------&gt;data-&gt;GetPointCells(pointID,CellNumber,cellIdArray);<BR>
<BR>
<BR>
<BR>
<BR>
LEak caused&nbsp; by vtkPolyData::Update()<BR>
<BR>
<BR>
<BR>
---------- Block 912 at 0x013A1790: 200 bytes ----------<BR>
&nbsp; Call Stack:<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkObject.cxx (31): vtkObject::operator new<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkFloatArray.cxx (26): vtkFloatArray::New<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkDataArray.cxx (634): vtkDataArray::CreateDataArray<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLReader.cxx (446): vtkXMLReader::CreateDataArray<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataReader.cxx (167): vtkXMLDataReader::SetupOutputInformation<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLUnstructuredDataReader.cxx (334): vtkXMLUnstructuredDataReader::SetupOutputInformation<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLReader.cxx (434): vtkXMLReader::SetupOutputData<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataReader.cxx (214): vtkXMLDataReader::SetupOutputData<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLUnstructuredDataReader.cxx (370): vtkXMLUnstructuredDataReader::SetupOutputData<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLPolyDataReader.cxx (197): vtkXMLPolyDataReader::SetupOutputData<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLReader.cxx (379): vtkXMLReader::ReadXMLData<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLUnstructuredDataReader.cxx (244): vtkXMLUnstructuredDataReader::ReadXMLData<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLReader.cxx (329): vtkXMLReader::ExecuteData<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkSource.cxx (408): vtkSource::UpdateData<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkDataObject.cxx (352): vtkDataObject::UpdateData<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkDataObject.cxx (251): vtkDataObject::Update<BR>
&nbsp;&nbsp;&nbsp; C:\vtkProjects\main\code\basic.cxx (96): main---------------------------------------------&gt;data-&gt;Update();<BR>
&nbsp;&nbsp;&nbsp; crtexe.c (338): mainCRTStartup<BR>
&nbsp;&nbsp;&nbsp;<BR>
<BR>
<BR>
<BR>
---------- Block 297 at 0x01399980: 3 bytes ----------<BR>
&nbsp; Call Stack:<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataElement.cxx (168): vtkXMLDataElement::SetAttribute<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataElement.cxx (106): vtkXMLDataElement::ReadXMLAttributes<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataParser.cxx (138): vtkXMLDataParser::StartElement<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLParser.cxx (471): vtkXMLParserStartElement<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (1641): doContent<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (1331): contentProcessor<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (2669): doProlog<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (2505): prologProcessor<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (2494): prologInitProcessor<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (1133): XML_ParseBuffer<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (1122): XML_Parse<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLParser.cxx (444): vtkXMLParser::ParseBuffer<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataParser.cxx (327): vtkXMLDataParser::ParseBuffer<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLParser.cxx (356): vtkXMLParser::ParseXML<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLParser.cxx (226): vtkXMLParser::Parse<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataParser.cxx (106): vtkXMLDataParser::Parse<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLReader.cxx (260): vtkXMLReader::ExecuteInformation<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkSource.cxx (222): vtkSource::UpdateInformation<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkDataObject.cxx (259): vtkDataObject::UpdateInformation<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkDataObject.cxx (248): vtkDataObject::Update<BR>
&nbsp;&nbsp;&nbsp; C:\vtkProjects\main\code\basic.cxx (92): main&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; --------------------------------------&gt;AnotherData-&gt;Update();<BR>
<BR>
<BR>
---------- Block 337 at 0x0139ADC0: 10 bytes ----------<BR>
&nbsp; Call Stack:<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataElement.h (42): vtkXMLDataElement::SetName<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataParser.cxx (135): vtkXMLDataParser::StartElement<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLParser.cxx (471): vtkXMLParserStartElement<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (1641): doContent<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (1331): contentProcessor<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (1331): contentProcessor<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (2669): doProlog<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (2505): prologProcessor<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (2494): prologInitProcessor<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (1133): XML_ParseBuffer<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Utilities\expat\xmlparse.c (1122): XML_Parse<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLParser.cxx (444): vtkXMLParser::ParseBuffer<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataParser.cxx (327): vtkXMLDataParser::ParseBuffer<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLParser.cxx (356): vtkXMLParser::ParseXML<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLParser.cxx (226): vtkXMLParser::Parse<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLDataParser.cxx (106): vtkXMLDataParser::Parse<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\IO\vtkXMLReader.cxx (260): vtkXMLReader::ExecuteInformation<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkSource.cxx (222): vtkSource::UpdateInformation<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkDataObject.cxx (259): vtkDataObject::UpdateInformation<BR>
&nbsp;&nbsp;&nbsp; C:\VTK\src\Common\vtkDataObject.cxx (248): vtkDataObject::Update<BR>
&nbsp;&nbsp;&nbsp; C:\vtkProjects\main\code\basic.cxx (92): main -----------------------------------&gt;AnotherData-&gt;Update();<BR>
<BR>
<BR>
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 ?<BR>
<BR>
Best Regards,<BR>
<BR>
<BR>
M.Salman<BR>
University of Surrey,U.K.<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>
<BR>
</FONT>
</P>

</BODY>
</HTML>