New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory management: recursively reference each parent xmlNode #360
Conversation
Parent refcount
…v_sibling Formatting Formatting
286eab2
to
29ad197
Compare
I will continue to review tomorrow. One direction that needs further study is interplay with libxml functions that mutate the graph. |
@teleological Thanks for the in-depth review |
It looks like however we resolve some issues – especially those related to So for example, Perhaps the copying is more targeted at the add sibling functions, which unlink the added node from any prior parent. By copying, it's not necessary to adjust the refcount at the origin node – at the expense of backwards compatibility, since it remains attached. It seems to me that it would be possible to account for the unlinking behavior without defeating it. |
} | ||
|
||
// recursively unref each parent | ||
void XmlNode::unref(int count) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little worried about this approach. Rather than explicitly counting references, why not hold an object which tracks referencing, similar to a smart pointer. This would be much safer than explicitly counting
Changes made by this pull request:
struct xmlNode
now has arefs
propertyObjectWrap::Ref
orObjectWrap::Unref
struct xmlNode
remove
andadd_child
now have refcount logiclibxmljs.nodeCount()
returns the number of nodes still in memory