Details
-
Bug
-
Status: Resolved
-
Resolution: Incomplete
-
1.5
-
None
-
None
-
Operating System: Other
Platform: PC
-
5311
Description
I got severe memory leaks when i parse XML Files with DOMParser class and using
DTD validation.
Here the simple main() routine of the test application:
void main()
{
try
catch(MissingEnvVariableException& e)
{ cout << endl << "Failure during initializing DCM environment!" << endl; cout << "Reason: " << e.getDescription() << endl; return; }catch(ParserInitializationException& e)
{ cout << endl << "Failure during initializing DCM environment!" << endl; cout << "Reason: " << e.getDescription() << endl; return; }catch(ModulesInitializationException& e)
{ cout << endl << "Failure during initializing DCM environment!" << endl; cout << "Reason: " << e.getDescription() << endl; return; }catch(...)
{ cout << endl << "Failure during initializing DCM environment!" << endl; cout << "Reason: unknown" << endl; return; } // run the test
testLoad_ImgSequence();
// Clean up DCM Environment (includes XMLPlatformUtils::Terminate())
Diamant::DCM_L::DCMEnvironment::ExitEnv();
int result=0;
result = _CrtDumpMemoryLeaks();
}
Here the parsing method:
void testLoad_ImgSequence()
{
ImageSequence* imgSeq=NULL;
int count=0;
while(count<100)
{
try
catch (InvalidParameterException& e)
{ imgSeq=NULL; }catch (DatafilebaseNotUniqueException& e)
{ imgSeq=NULL; }
catch (ParserErrorException& e)
{ imgSeq=NULL; }catch (XMLFileIOException& e)
{ imgSeq=NULL; }
catch (...)
{ imgSeq=NULL; } // clean up
if (imgSeq!=NULL) delete imgSeq;
cout << "ImageSequence loaded." << endl;
count++;
}
}
With each creation of a ImageSequence instance the given XML file is parsed and
some attributes in DOM are read:
ImageSequence::ImageSequence(...)
{
//...
// now load the image sequence data from xml
DOM_Element imageSeq = _XmlDocument.getDocumentElement();
// did we have a image sequence?
if(imageSeq!=NULL)
{
DOM_NamedNodeMap ISAttributes = imageSeq.getAttributes();
DOM_Node attribute;
DOMString attrName;
DOMString attrValue;
char* attrNameVal;
char* attrValueVal;
for(int32_t count=0;count<ISAttributes.getLength();count++)
{ attribute = ISAttributes.item(count); attrName = attribute.getNodeName(); attrValue = attribute.getNodeValue(); attrNameVal = attrName.transcode(); attrValueVal = attrValue.transcode(); // initialize the attributes of the image sequence if (!strcmp(attrNameVal,"FPS")) _Fps = atoi(attrValueVal); //... delete attrNameVal; delete attrValueVal; }}
The instrumentalized the Xerces Debug Lib with the Boundschecker and got a lot
of memory leaks, e.g.:
QName::QName(QName* const qname) constructor:
line: fLocalPart = new XMLCh[fLocalPartBufSz + 1];
unsigned int ElemStack::addChild(QName* const child, const bool toParent)
method:
curRow->fChildren[curRow->fChildCount++] = new QName(child);
etc.
I hope you can give some comments immediately.
Thanks in advance.