Hi,I think I've found a nice memory leak. I'm using xslt to reproduce it, but I think that bug is in xpath module, so I send it here.
The program is just transforming simple document in loop:
#include <libxml/parser.h>
#include <libxslt/xslt.h>
#include <libxslt/transform.h>
int main(int argc, char **argv) {
xsltStylesheetPtr cur;
xmlDocPtr doc, res;
xmlInitParser();
xmlSubstituteEntitiesDefault(1);
xmlLoadExtDtdDefaultValue = 1;
cur = xsltParseStylesheetFile("b.xsl");
while (1) {
doc = xmlParseFile("b.xml");
res = xsltApplyStylesheet(cur, doc, NULL);
xmlFreeDoc(res);
xmlFreeDoc(doc);
}
return(0);
}
Document (b.xml) is like that:
<?xml version="1.0"?>
<params xmlns="http://www.praterm.com.pl/SZARP/ipk">
<param>
<raport title="A"/>
</param>
</params>
and stylesheet:
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ipk="http://www.praterm.com.pl/SZARP/ipk">
<!-- <xsl:param name="title"/> -->
<xsl:template match="ipk:params">
<xsl:element name="report">
<xsl:for-each select="//ipk:param[ipk:raport[ title=$title]]">
<xsl:element name="param">
</xsl:element>
</xsl:for-each>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
The stylesheet is somewhat incorrect - declaration of parameter 'title' is
missing. This simple program keeps allocating more and more memory (can be
viewed with top/htop). When I uncomment the parameter declaration, everything
works OK.
And, btw - the output from valgrind differs when I use '--leak-resolution=high'.Checked with 2.6.18, but there's nothing about it in changelog, so I suppose its still there.
Files in attachment for convenience. Paweł Pałucha
Attachment:
xpath-memleak.tgz
Description: GNU Unix tar archive