> A single ruby object holding on to an xmlNode should inhibit
collection of an entire tree. Individual ruby xml nodes can be reaped, but there should be no xmlFree done by anything but the document level object. As for an xmlNode that is not associated with a document, it must call xmlFree (the xmlNode already indicates if it is associated with a document) if it has no parent. Which effectively translates into the same document semantics.
Agreed.I theorized this can be done by making a Ruby object give up ownership of its node when that node is added to a document (by setting the Ruby object's free method to null). Then during the mark phase the Ruby object should note it is dependent on the top level Ruby document object by:
ruby node -> xmlnode -> xmldocument -> ruby document.This means caching a back reference to the ruby document from the xml document in its private field.
If that all works, its should neatly solve the memory issues.
One operational change should be once an xmlNode is associated with a document it cannot be associated with another one (at least using the implicit copy mechanism provided in ruby_xml_node_child_set).
Do you mean a node can't be moved from one document to another (I can't see why not) or do you mean a node can't be in 2 documents at once (which makes perfect sense).
This should establish a bright line between libxml2 and ruby for managing memory.
Which is that ruby document objects hold the keys to the kingdom - once they go out of scope they free their associated xmldocuments which in turn free all its child nodes.
I intend to do this within a week. Post your warnings or wish me luck.
Good luck. Charlie
smime.p7s
Description: S/MIME Cryptographic Signature
_______________________________________________ libxml-devel mailing list libxml-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/libxml-devel