LightXML.jl icon indicating copy to clipboard operation
LightXML.jl copied to clipboard

set finalizer for XMLDocument by default

Open robertfeldt opened this issue 9 years ago • 4 comments

I propose most new users would rather prefer the finalizer is set by default. This does not solve the issue if people create their own XMLElement's but if they have a top-level XMLDocument the memory of it and all its sub-children will be gc'd once we no longer use the document.

robertfeldt avatar Jan 28 '15 08:01 robertfeldt

Do we end up needing to keep a reference count for all the child elements? What happens if you have child elements still around but the top-level document goes out of scope?

tkelman avatar Jan 28 '15 23:01 tkelman

Not sure, sorry. Sounds like it would wreak havoc... ;) Maybe keep it as a manual option then and people have to set the finalizer themselves.

robertfeldt avatar Jan 29 '15 00:01 robertfeldt

Should README.md be edited to say we don't need to free xdoc explicitly anymore? Are the examples in there canonical?

tonyhffong avatar Feb 01 '15 03:02 tonyhffong

Unless there's a way to tell Julia's gc that child nodes are referring to the document and it should be kept alive until all of its children are also out of scope, I don't think setting a finalizer on xdoc is actually safe. Though we need to so some more experiments to be sure.

tkelman avatar Feb 01 '15 03:02 tkelman