Re: [xml] memory allocation problem
- From: Daniel Veillard <veillard redhat com>
- To: Miroslav Ruda <ruda ics muni cz>
- Cc: xml gnome org
- Subject: Re: [xml] memory allocation problem
- Date: Wed, 9 May 2007 19:20:09 -0400
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]