From: Tal Yalon Date: 2011-02-09T00:07:10+09:00 Subject: Memory leak in 1.9.2-p330? --0016363b8d8cc19e39049bc6b346 Content-Type: text/plain; charset=ISO-8859-1 Hi all, Before I go and submit a bug report, I would appreciate a fresh pair of eyes hopefully finding a bug in the code and not in Ruby :) The code pushes elements to a "time window" queue of 2 seconds. Although I see that the maximum queue size stabilizes after a very short time (couple of seconds), the process's max RSS size starts to grow after a while 2 minutes. Interestingly enough, the max RSS size stays fixed when running with 1.8.7. All tests were done on Ruby compiled using rvm. Printing the process's RSS and max RSS size was done to observe the leak in action, This code also leaks when removing the lines that execute ps and print it. Any idea will be welcomed. Thanks, Tal #!/usr/bin/env ruby before = Time.now.to_i i = 0 max_rss = 0 max_items = 0 queue = [] while true now = Time.now.to_i windows_start_time = now - 2 queue << now while not queue.empty? and queue[0] < windows_start_time queue.shift end if now - before >= 1 max_items = [ max_items, queue.size ].max rss = `ps -o rss= -p #{Process.pid}`.to_i max_rss = [ max_rss, rss].max print("#{now} iters=#{i} queue_size=#{queue.size} rss=#{rss}, max: queue_size=#{max_items}, rss=#{max_rss}\n") before = now end i += 1 end --0016363b8d8cc19e39049bc6b346--