Moxml maintains a node registry to ensure consistent object mapping:
doc=context.parse(large_xml)# Process documentdoc=nil# Allow garbage collection of document and registryGC.start# Force garbage collection if needed
Efficient querying
Use specific XPath expressions for better performance:
# More efficient - specific pathdoc.xpath('//book/title')# Less efficient - requires full document scandoc.xpath('//title')# Most efficient - direct child accessroot.xpath('./*/title')