#24 Valgrind reporting memory leak in XMLStream::parse

Library (32)
James Vanns

Valgrind continues to report 'definitely' lost bytes in
my application at the point where it calls the parent
class (XMLStream) parse() method.

When compiled to use libxml2 it suggests a memory leak
(through malloc) when calling xmlCreatePushParserCtxt
in XMLStream::parse(const char*).

It appears to be the only place where a memory leak is
reported in my application - and it is indeed leaking
memory. After a few days the daemon using this library
has consumed 50% of the memory on the machine - never
giving it back to the OS.

Could someone, somehow double check this for me? I am
running FC3 on a 2.6.12 kernel, g++ 3.4.4 the latest
version of libxml2 and common c++.


Jim Vanns


  • David Sugar

    David Sugar - 2006-07-17
    • assigned_to: nobody --> dyfet
  • David Sugar

    David Sugar - 2006-07-17

    Logged In: YES

    It looks like it does call the matching
    xmlFreeParserCtxt...maybe the xml->sax = NULL is causing
    this since it is something that should be cleared in

  • James Vanns

    James Vanns - 2006-07-17

    Logged In: YES

    Right I can confirm (with almost a shadow of doubt!) that
    there is some sort of memory leak when using the-libxml2
    enabled code in XMLStream. I have recompiled Common C++
    disabling xml2 support (e.g. --without-libxml2) and I do not
    get the memory leak. Or at least I haven't yet! This app is
    multi-threaded and makes heavy use of XMLStream. I will know
    more tomorrow morning when the app has been running > 12h
    without interruption.


  • James Vanns

    James Vanns - 2006-07-19

    Logged In: YES

    OK, I can now confirm after running the daemon for a few
    days with approx ~30 (1 per connecting thread) XMLStream
    instantiations per second and disabling libxml2 support in
    CommonC++ (at compile time) that no memory leak occurs as it
    did (previously reported - see above). I am unsure where the
    leak is then in commoncpp' XMLStream class but I did realise
    that 'this' is passed to the xmlCreatePushParserCtxt
    function. The way I use the XMLStream class (or derivative
    thereof) though it is allocated on the stack - not on the
    heap so I don't know what xmlCreatePushParserCtxt tries to
    do with the pointer.


  • David Sugar

    David Sugar - 2007-01-24

    Logged In: YES
    Originator: NO

    Newer cc++ releases now use the common c++ xml parser rather than libxml2...

  • David Sugar

    David Sugar - 2007-01-24
    • status: open --> closed

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks