From: Grant Schoep Date: 2012-06-06T06:49:50+09:00 Subject: XML::Parser, keeping file open Using: Ruby 1.9.2p136 libxml-ruby (1.1.4) on RHEL 5.7 I have an application that seems to not be cleaning up xml files as I read them. I can force it to clean up by manually running GC.start. But I'd like to understand how to really close this, like you can do xyz = File.open ... xyz.close Using a block, or the example above, I know that file is closed... But for xml files... Here is a nice simple example that reproduces it for me. When I run the below example, and execute lsof on the running process, I see there are four instances of the xml file open. If I uncomment the "GC.start" line. It leaves all but ONE instance open. Now, this is a simple example, eventually the GC will clean things up. But I'd like to clean it up myself, and not rely on the garbage collector to do it at some point. I'd also rather not just force the garbage collector to run like I show in my example. Thanks ------------------------------------------------------ require 'xml/libxml' def readIt() parser = XML::Parser.file("someFile.xml") parser = nil end while true readIt() readIt() readIt() readIt() # GC.start puts "Sleeping" sleep 100 end ------------------------------------------------------------ -- Posted via http://www.ruby-forum.com/.