In message <[EMAIL PROTECTED]>
          Charlie Savage <[EMAIL PROTECTED]> wrote:

> > The problems that I have discovered stem from libxml freeing entire
> > document trees while there are still ruby objects referencing the nodes.
> > When those ruby objects are subsequently garbage-collected, the xmlNodes
> > in those objects have already been freed and sadness ensues.  But I
> > think the current mechanism is so close to working that it does not
> > warrant a complete rewrite.
> 
> Why would a Ruby object "own" a xmlnode in a document tree?  Can that be
> avoided?

Simple - you create an element object in ruby, then add that element
as the child of another element. The ruby element object still exists
and still points at the same element though (and can be used to make
changes to that element in the tree).

> If not, can you install a callback into libxml to be alerted when a node
> is freed?  If so, then you could decrement the reference count.  But
> you'd still have to keep some long-term memory around so that any
> existing Ruby objects pointing to the node could check the reference
> count and see if it is zero. How do you know when to free that memory?
> I see no way, unless you go to the Ruby object <-> libxml object mapping
> like I described in the last email.

You can install callbacks, yes - that is what my patch does.

Tom

-- 
Tom Hughes ([EMAIL PROTECTED])
http://www.compton.nu/
_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to