Re: [xml] memory leak while parsing from memory buffer

On Wed, Apr 07, 2004 at 07:48:49PM +0200, Petr Pajas wrote:
But, although ctxt->input->filename _does_ get freed with
xmlFreeParserCtxt, the above code leaks. If the line with xmlStrdup is
removed, the leak disappears. I suspect, that somewhere, during
xmlParseDocument some copies of filename are made but never freed or
something similar. Otherwise I don't know why this line would make any
difference. BTW, it's the same if I set

ctxt->input->filename = "";

and put 

ctxt->input->filename = NULL;

just before xmlFreeParserCtxt(ctxt).

Any hints?

  that would mean that the error handling code leaks.
For some reasons it doesn't seems to occur in the common path
of libxml2, even when trying to reproduce exactly the same prob
with a libxml2 compiled with memory debug (

paphio:~/XML -> xmllint --memory --valid --noout tst.xml
tst.xml:4: element bar: validity error : No declaration for element bar
paphio:~/XML -> cat .memdump
      07:59:25 PM
      MEMORY ALLOCATED : 0, MAX was 19218
paphio:~/XML ->

  --memory --valid options should reproduce the parser options you
detailed, so I'm a bit puzzled.

  valgrind or using other memory detection tools might help track this


Daniel Veillard      | Red Hat Network
veillard redhat com  | libxml GNOME XML XSLT toolkit | Rpmfind RPM search engine

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