Re: Antwort: Re: LibXML and $node->nodePath
by Petr Pajas other posts by this author
Jun 16 2006 2:56PM messages near this date
view in the new Beta List Site
Re: XML::LibXML Catalogs problem
|
LibXML and $node->nodePath
& XSLT ...replying the list.
On Friday 16 June 2006 17:40, Bernd Krause wrote:
> Dear Petr,
>
> thank you very much for your help on that problem. I am happy you could
> find the fix easily. Would you send a note to the perl-xml mailing list
> when your patch has been applied to the CVS?
It just has:-) Matt promptly reopened my axkit account. Use
cvs -d:pserver:anonymous@cvs.axkit.org:/home/cvs -z3 co XML-LibXML
to check out.
> I am using the compiled
> library from Randy Kobes, so I'll have to wait until Randy updates his
> binaries.
Bad luck then, I don't think Randy's builds are based on CVS snapshots and I'm
not aware of any recent activity leading to a release in the near future (but
I may be wrong).
> Anyway, it is a great module, thanks to everybody who is working on it.
Unfortunately, nobody seems to be actively working on it these days (including
myself I must say) :-(
> And
> maybe after application of your patch the ->nodePath method can go into the
> documentation on CPAN?
Well, the documentation is in the CVS (one has to call 'make docs', though).
It'll appear on CPAN as soon as a new release is made...
-- Petr
> -----Petr Pajas <pajas@[...].cz> schrieb: -----
>
> An: perl-xml@[...].com
> Von: Petr Pajas <pajas@[...].cz>
> Datum: 16.06.2006 01:28PM
> Kopie: Bernd Krause <Bernd.Krause@[...].de>
> Thema: Re: LibXML and $node->nodePath
>
> On Friday 16 June 2006 10:54, Bernd Krause wrote:
> > Hi,
> >
> > I am using the XML::LibXML function $node->nodePath. This is not a
> > documented function but has been discussed on this list.
> > I am observing a memory leak as soon as I use $node->nodePath.
> >
> > Consider the following sample code:
> > =========================================
> > use strict;
> > use XML::LibXML;
> >
> > my $i = 0;
> > my $loop_end = 20000;
> > my $xml_string = '<?xml
> > version="1.0"?><root><aaa><bbb/><ccc/></aaa><ddd><bbb/><eee/></ddd></root
> >>' ;
> >
> > my $parser = XML::LibXML->new();
> > my $tree = $parser->parse_string($xml_string) || die;
> > for ($i = 0; $i <= $loop_end; $i++) {
> >
> > Â Â Â Â my $root = $tree->getDocumentElement;
> > Â Â Â Â my $dtd = $root->nodeName;
> > Â Â Â Â my $xpath_string = "//*";
> >
> > Â Â Â Â foreach my $node ($tree->findnodes("$xpath_string")){
> > Â Â Â Â Â Â Â Â my $xPath = $node->nodePath; Â Â # Â Â Â Â <- problem
> > Â Â Â Â }
> > Â Â Â Â print $i, "\t", $dtd, "\n";
> > }
> > =========================================
> >
> > If the above code is executed, computer memory consumption increases
> > linearly with $loop_end.
> > However, removing the $node->nodePath instruction immediately resolves
> > the problem: memory consumption remains constant independant of
> > $loop_end.
> >
> > This is not a real problem for single file parsing. The problem occurs
> > because I have to parse a large number of XML files (much larger and more
> > complicated than in the example above). LibXML does a great job on that,
> > it is only the $node->nodePath which eats up all memory and makes my
> > computer stop working.
>
> A totally stupid bug indeed. The definition of nodePath in LibXML.xs misses
> a xmlFree call. It should look like:
>
> nodePath( self )
> Â Â Â Â xmlNodePtr self
> Â Â PREINIT:
> Â Â Â Â xmlChar * path = NULL;
> Â Â CODE:
> Â Â Â Â path = xmlGetNodePath( self );
> Â Â Â Â if ( path == NULL ) {
> Â Â Â Â Â Â croak( "cannot calculate path for the given node" );
> Â Â Â Â }
> Â Â Â Â RETVAL = nodeC2Sv( path, self );
> Â Â Â Â xmlFree( path ); /* this line was missing !!! */
> Â Â OUTPUT:
> Â Â Â Â RETVAL
>
> Since axkit was reinstalled I don't have write access to the CVS, so I
> can't fix it permanently ATM. I'll see what I can do about it.
>
> -- Petr
>
> > My Perl/LibXML environment is:
> >
> > Windows 2000
> > Active State PERL v5.8.3
> >
> > XML::LibXML::LIBXML_DOTTED_VERSION -> Â 2.6.11
> > XML::LibXML::LIBXML_VERSION -> Â 20611
> > XML::LibXML::VERSION -> 1.58
> >
> > Is there any way to prevent $node->nodePath from consuming all memory?
> > Thanks in advance for any help,
> > Bernd
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
|