Re: [xml] xmlParserCtxt Leak?



Thank you for your reply. I realize that I may have been brush in accusing your work; I apologize. I've made the changes you've suggested, but the same results from Valgrind keep showing up. Even after adding xmlParserCleanup(), there are 10 allocs and 9 frees leaving 84 bytes "still reachable". I can post more information if you need it, and I will try to compile this against a library with mem- debug as soon as possible.

Also, while I am a beginner, I have read everything there is to read on xmlsoft.org. I'll take a look myself at the source, but I simply felt it was better left in the hands of people who know what they're doing.

Thank you,
Michael


On Jun 15, 2008, at 4:22 AM, Daniel Veillard wrote:

On Fri, Jun 13, 2008 at 05:00:02PM -0700, mt2 wrote:
Hello all,
I've just started using xmlParserCtxtInit() and friends to create a
reusable parser to parse lots of documents in a row (this is the right
thing to do, keep the parser context alive and parse new documents)
though I've detected what I think is a memory leak. I wrote a small

Ho did you detected that ? There is many way people usually get fooled
just because they don't understand how memory allocators work.

program to test the way I am working with libxml. If I am reading
valgrind's output correctly (there's a real change I'm not) this small
program is missing one free(); I've attached it's output, too.

 you're missing one call at the end of the program

Finally, I might be using the parser API incorrectly (and there's a
good chance for that), so if anyone could point me in the right
direction there, too, I'd be much obliged. Also,

 No idea as you didn't provide an exemple reproducing a leak here.

xmlMemoryDump() doesn't seem to output anything? On Ubuntu, I'm using

probably because it wasn't compiled with memory debug, which is normal
as it's not a default.

2.6.31, and on Windows I'm using 2.6.32; I've reproduced this on both
platforms-- I'm at a loss here...

#include <libxml/parser.h>

int main()
{
        xmlParserCtxtPtr ctxt = xmlNewParserCtxt();
        xmlInitParserCtxt(ctxt);

        xmlFreeParserCtxt(ctxt);
        
       xmlMemoryDump();

       xmlCleanupParser() missing at the end of the program

        return 0;
}


 What about reading the documentation ?

   http://xmlsoft.org/xmlmem.html

Daniel

--
Red Hat Virtualization group http://redhat.com/virtualization/
Daniel Veillard      | virtualization library  http://libvirt.org/
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]