GNOME Bugzilla – Bug 707418
Python libxml2/ libxslt append unlinkedNode to new xmldoc from transformed result produces memory-leak
Last modified: 2021-07-05 13:21:57 UTC
When running current python code, i get a memory-leak. The xmldoc result seems to be corrupt or not compatible with new xmldocs after transformation. This is problematicaly, because there are no way to join multiple transformed xmldocs without copying the nodes or reparse xmldocs. The libxml2 and libxslt binding are perfect for multiple transformations and join operations, because libxslt accept an xmldoc for transformation and also returns one which makes processing really fast. But with this bug this is an real performance show-stopper. Same bug was observed in the Perl-Bindings which is a hint that the bug must be in the c-library. I also tried to transform the doc which an transform_ctxt and the libxml2.XML_PARSE_NODICT option, but without success. import libxml2 import libxslt # XSLT Transform doc = libxml2.parseDoc(""" <result> <result>abc</result> <result>def</result> </result> """) styledoc = libxml2.parseDoc(""" <xsl:stylesheet version='1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform'> <xsl:template match='/'> <xsl:copy-of select="*"/> </xsl:template> </xsl:stylesheet> """) xsl_transform = libxslt.parseStylesheetDoc(styledoc) xml_result_doc = xsl_transform.applyStylesheet(doc, {}) xsl_transform.freeStylesheet() doc.freeDoc() # Unlink Node from XSLT-Transformed result xml_result_root = xml_result_doc.getRootElement() xml_result_root.unlinkNode() xml_result_root.setTreeDoc(None) xml_result_root.freeNode() xml_result_doc.freeDoc()
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a new ticket at https://gitlab.gnome.org/GNOME/libxml2/-/issues/ Thank you for your understanding and your help.