Re: [xml] Memory not going away.. SOLUTION



On Tue, Mar 08, 2005 at 01:01:26PM -0500, David W. Bauer Jr. wrote:

Recall I had:

        xmlXPathInit();
        document_network = xmlParseFile(filename);
        ctxt = xmlXPathNewContext(document_network);

        xmlXPathFreeContext(ctxt);
        xmlFreeDoc(document_network);
      xmlCleanupParser();
        xmlMemoryDump();

The solution:

        xmlXPathInit();
        document_network = xmlParseFile(filename);
      ctxt = xmlXPathNewContext(document_network);

        xmlXPathFreeContext(ctxt);
        xmlCleanupParser();
        xmlFreeDoc(document_network);
        xmlMemoryDump();

Notice that I need to cleanup the parser prior to freeing the document.

  Makes absolutely no sense. xmlCleanupParser() is a library wide
memory deallocation, you should not call it while you had document allocated
since they could now point to freed area (example predefined entities).
I think your methodology of test is wrong, and the programming way of
trying anything until it seems to work to not be better. Read the doc
dor xmlCleanupParser() it is very clear you should not do this.

Daniel

-- 
Daniel Veillard      | Red Hat Desktop team http://redhat.com/
veillard redhat com  | libxml GNOME XML XSLT toolkit  http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/



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