Memory leak or bad code?
422375May 31 2004 — edited Jun 30 2004Hi there,
Ive been experimenting with the XML parser for C++ from Release 2 (9.2) and I came up with the following situation:
I took some code from the demo folder and added a `for loop` around the createElement and appendChild.
The code looks like this:
if (ecode = parser.xmlinit())
{
cout << "Failed to initialze XML parser, error " << ecode << "\n";
return 1;
}
cout << "\nCreating new document...\n";
if (!(doc = parser.createDocument((oratext *) 0, (oratext *) 0,(DocumentType *) 0)))
FAIL
for(int i=0;i<count;i++)
{
if (!(elem = doc->createElement((oratext *) "ROOT")))
FAIL
if (!doc->appendChild(elem))
FAIL
}
parser.xmlterm();
My problem is that, after the parser.xmlterm() the memory usage is still the same. I work on a HPUX machine and the memory usage is shown in the TOP utility. Example: if count =100000, TOP shows a size and res of 227M and 205M respectively before the xmlterm and no change is shown after the xmlterm. So is there a leak or is my code not good?
A quick reply from you will be mostly appreciated,
Thank you,
Avinash.