Re: [xml] memory allocation problem

On Wed, May 09, 2007 at 10:11:09AM +0200, Miroslav Ruda wrote:


 I have tried to used libxml2 to parse simple XML document and I have problem
with memory leaking. My code is:


for(;;) {
  root_element = xmlDocGetRootElement(doc);


While running in cycle, memory usage is growing. According valgrid, all memory
is correctly freed in xmlCleanupParser(), but because I'm in indefinite loop,
memory is not released between two cycles ...

And the same code is used in several threads - therefore I'm not able to call
xmlInitParser()+xmlCleanupParser() in each cycle.

Any suggestions?

  Check your operating system malloc/free behaviour, you didn't tell what 
is used here, I see no leak in the provided code (unless check_element leaks)
and I don't see any problem. xmllint --repeat does repeated parse/free of trees
and I don't see it's memory usage exploding.
   If you can reproduce that memory usage explosion with xmllint --repeat,
provide the document used to show this.


Red Hat Virtualization group
Daniel Veillard      | virtualization library
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]