I couldn't get Rubyforge to behave when creating the patch though so I've just sending it to the list.
Thanks Sean
memory_leak_patch.diff
Description: Binary data
On 05/06/2009, at 8:42 AM, Sean Geoghegan wrote:
Hi libxml-ruby folkI have some long running scripts that parse lots of XML files over a long period of time using XML:Reader and I've been having what appears to be memory leak problems with them. It seems that the read_string method of XML::Reader is the cuplrit. I've narrowed it down to simple test case. Here is the code:require 'rubygems' gem 'libxml-ruby', '>= 1.1.2' require 'xml/libxml' def parse() x = XML::Reader.string("<foo>this is bar</foo>") x.next x.read_string # This line causes the leak x.close end 1.upto(2000000) do |i| parse GC.start if i % 1000 == 0 endIf you comment out the "x.read_string" line everything is fine, it will only use about 20MB of memory, uncomment it however and it will quickly race to 1GB of memory usage. I've tried various ObjectSpace memory inspectors such as Dike but it doesn't show anything that could account for the rapid growth in usage, which makes me think it is a leak in the C extension.Versions are: libxml = 2.6.32 libxml-ruby = 1.1.2 Ruby = 1.8.6 p287I've only tested the above script on OSX but I have experience the leak on various flavours of Linux with Ruby 1.8.5 and 1.8.6.I'll keep investigating and start looking at the C code of libxml- ruby next, but I thought I'd let someone know about it at this stage.Thanks Sean Geoghegan
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ libxml-devel mailing list libxml-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/libxml-devel