G
gchandran
Hi All,
Problem: Call to DOMDocument::getElementsByTagName() in a loop causes
growth in memory consumption?
Consider the following lines of code which simulates the problem
that I am facing.
/////////////////////////////////////////////////////////////////
m_doc = m_parser->getDocument() ;
char * usnLookUpValue = new char[10];
char dest[10] = {0};
int iIndex = 0;
while(1)
{
memcpy(usnLookUpValue,dest,10);
sprintf(usnLookUpValue,"U%d",iIndex++);
XMLCh* fUnicodeForm = XMLString::transcode(usnLookUpValue);
DOMNodeList* resultNodes = NULL;
resultNodes = m_doc->getElementsByTagName(fUnicodeForm);
XMLString::release(&fUnicodeForm);
if(iIndex > 50000)
{
iIndex = 0;
break;
}
}
delete usnLookUpValue;
delete m_Serializer ;
delete m_parser;
XMLPlatformUtils::Terminate();
//////////////////////////////////////////////////////////////////
The call to "getElementsByTagName" in the loop causes growth in memory
consumption until the Parser object is deletetd.
As per my understanding of Xerces C++ DOM there is no need to release
the object returned by getElementsByTagName which is owned by
implementation. The memory associated to these objects are released
when we release the Document object.
What can be the solution/alternative to prevent the rise in memory
consumption?
Any pointers would be welcome.
thanks and regards,
Girish
Problem: Call to DOMDocument::getElementsByTagName() in a loop causes
growth in memory consumption?
Consider the following lines of code which simulates the problem
that I am facing.
/////////////////////////////////////////////////////////////////
m_doc = m_parser->getDocument() ;
char * usnLookUpValue = new char[10];
char dest[10] = {0};
int iIndex = 0;
while(1)
{
memcpy(usnLookUpValue,dest,10);
sprintf(usnLookUpValue,"U%d",iIndex++);
XMLCh* fUnicodeForm = XMLString::transcode(usnLookUpValue);
DOMNodeList* resultNodes = NULL;
resultNodes = m_doc->getElementsByTagName(fUnicodeForm);
XMLString::release(&fUnicodeForm);
if(iIndex > 50000)
{
iIndex = 0;
break;
}
}
delete usnLookUpValue;
delete m_Serializer ;
delete m_parser;
XMLPlatformUtils::Terminate();
//////////////////////////////////////////////////////////////////
The call to "getElementsByTagName" in the loop causes growth in memory
consumption until the Parser object is deletetd.
As per my understanding of Xerces C++ DOM there is no need to release
the object returned by getElementsByTagName which is owned by
implementation. The memory associated to these objects are released
when we release the Document object.
What can be the solution/alternative to prevent the rise in memory
consumption?
Any pointers would be welcome.
thanks and regards,
Girish