ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
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

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved