On Fri, 09 Jun 2006 21:07:47 +0100, Dan Janowski <[EMAIL PROTECTED]> wrote:

> Hi,
>
> Has there been a discussion about the memory-model changes? If so, I
> am interested to understand the direction better. Is there a
> particular list thread that I might read?
>

Sean and I have discussed it a little bit, though it must have been  
offlist since I can't find it in the archive :I . There are a few threads  
about problems / bugs caused by memory handling, e.g. the segfault bug  
Doug Bryant reported recently:

        http://rubyforge.org/pipermail/libxml-devel/2006-June/000162.html

> In my past ruby extensions I have avoided giving the GC any more than
> necessary, to limit memory copying as well as performance. Is the
> libXML memory model unstable to keep pointer references to?
>

Not especially, there are just a few special cases that we don't currently  
cater for, such as when copying nodes between documents. If a node pointer  
is added to a second document, and them xmlFreeDoc is called on the first,  
that pointer becomes invalid and will cause a segfault either when the  
document is accessed, or when xmlFreeDoc is called on it. So in this case,  
I think we do need to do a recursive copy of the nodes, so that they can  
be garbage collected with the new document. I'm still learning the  
intricacies of libxml2 but this is how it looks to me right now.

I'm not planning to copy indiscrimiately, however - pointers will probably  
be retained to nodes copied within the same document, and with attributes  
wherever possible. Mainly I'm looking at rationalizing our memory  
handling, cleaning up and making sure we're using the right  
ruby_xml_whatever_new[123 etc.] function in the right place.

-- 
Ross Bamford - [EMAIL PROTECTED]
_______________________________________________
libxml-devel mailing list
libxml-devel@rubyforge.org
http://rubyforge.org/mailman/listinfo/libxml-devel

Reply via email to