[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: [xml] ¿leak using libxml2 for sax-parsing html in python?
- From: Daniel Veillard <veillard redhat com>
- To: Cesar Ortiz <cesar ortiz name>
- Cc: xml gnome org
- Subject: Re: [xml] ¿leak using libxml2 for sax-parsing html in python?
- Date: Tue, 9 Jan 2007 16:30:41 -0500
On Tue, Jan 09, 2007 at 05:12:16PM +0100, Cesar Ortiz wrote:
> Hi again,
> It has sense what you say. I changed the test code to force the calling of
> htmlFreeParserCtxt and it works the same ;).
>
> I have also done a translation of the example to C, and it works nicely in
> my environtment.
>
> One last attempt about the python example... I am sending you the testing
> python code and a html file it uses. You just have to run it and check the
> memory with top (or checking /proc) to see the memory consumption (If
> instead a for loop you change it with an infinite loop the system gets out
> of memory. Could you just say to me how the memory consumption evolves in
> your environment? (Your memory functions report that everything is OK.)
We investigated the problem with William, and I think we have it nailed
down in SVN: Committed revision 3573 , it was basically reference counting of
sttribute strings passed in a dictionnary which were not decremented leading
to the leak.
Patch enclosed,
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/
Index: ChangeLog
===================================================================
--- ChangeLog (revision 3572)
+++ ChangeLog (revision 3573)
@@ -1,3 +1,8 @@
+Tue Jan 9 22:24:26 CET 2007 Daniel Veillard <daniel veillard com>
+
+ * python/libxml.c: fix a memory leak in the python string handling
+ when SAX event are passed back to the python handlers
+
Thu Jan 4 18:27:49 CET 2007 Daniel Veillard <daniel veillard com>
* xmlreader.c: fix xmlTextReaderSetup() description
Index: python/libxml.c
===================================================================
--- python/libxml.c (revision 3572)
+++ python/libxml.c (revision 3573)
@@ -773,6 +773,8 @@
attrvalue = Py_None;
}
PyDict_SetItem(dict, attrname, attrvalue);
+ Py_DECREF(attrname);
+ Py_DECREF(attrvalue);
}
}
@@ -1170,6 +1172,7 @@
for (node = tree; node != NULL; node = node->next) {
newName = PyString_FromString((char *) node->name);
PyList_SetItem(nameList, count, newName);
+ Py_DECREF(newName);
count++;
}
result = PyObject_CallMethod(handler, (char *) "attributeDecl",
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]