[xml] quite huge memory consumption



Hi folks,

I have a little XML file (13MB), containing 250 entries, scheduling
information.
Now, I am surprised to see, that xmlParseFile uses around 600MB to
store information on that file.

The way we parse it looks like that (pseudo code):

xmlInitParser();
doc = xmlParseFile(fn);

context = xmlXPathNewContext(doc);
s = xmlXPathEvalExpression(sTag, context);
for(int j=0; j < s->nodesexyal->nodeNr; j++)
{
    if(NULL != s->nodesetval->nodeTab)
    {
      if(NULL!=(sNode = s->nodesetval->nodeTab[j]))
       {

          p = xmlGetProp(node, prop);
             ...
          xmlfree(p);

          xmlDocSetRootElement(sDoc, sNode);
          xy = xmlXPathEvalExpression(xyTag, context);

           .........
           r = xmlXPathEvalExpression(rTag, context);
           ......
           xmlXPathFreeObject(r);
           xmlXPathFreeObject(xy);
         }
      }
}
xmlXPathFreeObject(s);
xmlXPathFreeContext(context);
xmlFreeDoc(sDoc);
unlink(filename.c_str());

xmlCleanupParser();


so the memory consumption goes to 700 after xmlFileParse, and stays so
high, even after xmlCleanupParser.

any ideas ?
it is libxml2-2.6.23-1 on centos 4.1 (and cannot change that).


-- 
GJ



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]