[xml] xmlParserCtxt Leak?



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
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.
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,
xmlMemoryDump() doesn't seem to output anything? On Ubuntu, I'm using
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();
        return 0;
}

==9728== Memcheck, a memory error detector.
==9728== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward et al.
==9728== Using LibVEX rev 1804, a library for dynamic binary translation.
==9728== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
==9728== Using valgrind-3.3.0-Debian, a dynamic binary instrumentation
framework.
==9728== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward et al.
==9728== For more details, rerun with: -v
==9728==
==9728==
==9728== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 19 from 1)
==9728== malloc/free: in use at exit: 84 bytes in 1 blocks.
==9728== malloc/free: 10 allocs, 9 frees, 2,952 bytes allocated.
==9728== For counts of detected errors, rerun with: -v
==9728== searching for pointers to 1 not-freed blocks.
==9728== checked 109,356 bytes.
==9728==
==9728== LEAK SUMMARY:
==9728==    definitely lost: 0 bytes in 0 blocks.
==9728==      possibly lost: 0 bytes in 0 blocks.
==9728==    still reachable: 84 bytes in 1 blocks.
==9728==         suppressed: 0 bytes in 0 blocks.
==9728== Rerun with --leak-check=full to see details of leaked memory.

 xmllint --version
xmllint: using libxml version 20631
   compiled with: Threads Tree Output Push Reader Patterns Writer
SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer
XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas
Schematron Modules Debug Zlib



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