From: Rob Doug Date: 2009-10-20T23:27:48+09:00 Subject: Re: memory leak > You'll have to share more of your implementation then. You deduced that > the cause wasn't threads, but you've only shared the threaded part of > your code. > > Also, have you run your program with valgrind to verify that it is in > fact a memory leak? It could just be objects sitting around waiting for > GC. Here the rest part of program, I did not think here can be any leaks, this is why I posted code without this part. module Common def Common.post_it(link) begin puts link agent = Net::HTTP html = agent.get(URI.parse(link)) doc = Hpricot(html) forms = doc.search "//form" forms.each do |form| puts form.search("input").length end rescue => err puts err file_write_safe("logs/errorlog.txt", "#{err.to_s}|#{link}\n") return false rescue Timeout::Error file_write_safe("logs/errorlog.txt", "Request Timeout|#{link}\n") end end private def self.file_write_safe(file,message) File.open(file, 'a') { |f| f.flock(File::LOCK_EX) f.write(message) f.flock(File::LOCK_UN) } end end -- Posted via http://www.ruby-forum.com/.