On 8 May 2000, (Randal L. Schwartz) wrote:

> >>>>> "Matt" == Matt Sergeant <[EMAIL PROTECTED]> writes:
> 
> Matt> I don't think that's true - or I'm misunderstanding what you're
> Matt> saying. When I go:
> 
> Matt> $node->appendChild($othernode);
> 
> Matt> it calls $$node->appendChild($othernode), and appends the actual othernode
> Matt> onto the list of children. So whenever you're iterating over children
> Matt> you're getting the actual node, not the sub-node.
> 
> I'm talking about the return from ->find, like so:
> 
> my $xp = XML::XPath->new(filename => 'test.xhtml');
> my $found_node = $xp->find('/html/body/p');
> 
> Now, $found_node is either a wrapper or the 'true' object.  If it's
> the true object (part of the $xp tree), and I let $xp go out of scope
> before $found_node, that should start your destruction of the tree
> that includes $found_node, which means my data gets blasted even
> though I've got a pointer into it.  Or, if you don't forcefully
> destroy the data, you'll leave me pointing to a self-referencing data
> structure, which will be a memory leak when I finally toss
> $found_node.

Ack you're right. Still, I think it's better to have this ability to
garbage collect, and a note in the docs: "Don't let your tree go out of
scope if you're still interested in your result tree. Even though it's a
fragment, the 'magic' garbage collection will start tossing your nodes
into the trash. You have been warned".

I think the number of cases where you let $xp go before the results will
be pretty minimal, unless you can come up with a real good situation where
that won't be the case.

-- 
<Matt/>

Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org http://xml.sergeant.org


---
You are currently subscribed to perl-xml as: [[email protected]]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to