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

Re: [xml] memory allocation problem



On Wed, May 09, 2007 at 10:11:09AM +0200, Miroslav Ruda wrote:
> 
> Hello,
> 
>  I have tried to used libxml2 to parse simple XML document and I have problem
> with memory leaking. My code is:
> 
> xmlInitParser();
> 
> for(;;) {
>   doc=xmlParseMemory(buf,len);
>   root_element = xmlDocGetRootElement(doc);
>   check_element(root_element);
>   xmlFreeDoc(doc);
> 
>   sleep(1);
> }
> xmlCleanupParser();
> 
> 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.

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]