Re: [xml] quite huge memory consumption



Hi,

 I would like to extract from information starting from a file XML to
use them afterwards in my program C with Visual studio 2008 Windows
XP. This file XML is voluminous.

I see that LibXml2 is a little difficult. Moreover, I do not find the
assistance.

- Can you give me an example of program C which use LibXml2 for
extract some information from  a file XML ?


there is somebody who says to me:
You do not need of library for parser XML: there are MSXML and other
SAX2 and the interfaces of the IXMLDocument kind in MSDN.

- Can you help me step by step on a small example of file XML in a
program C to understand how I will use MSXML ?



Thank you.

2009/7/24, Grzegorz JaÅkiewicz <gryzman gmail com>:
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
_______________________________________________
xml mailing list, project page  http://xmlsoft.org/
xml gnome org
http://mail.gnome.org/mailman/listinfo/xml




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