How does Xerces C++ release DOMNodeList object?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,983
Messages
2,570,187
Members
46,747
Latest member
jojoBizaroo

Latest Threads

Top