On Oct 19, 2009, at 18:10 , Rob Doug wrote: > links = IO.read("bases/3+4.txt").split("\n") > threads = [] > > links.each do |link| > if Thread.list.size < 50 then > threads << Thread.new(link) { |myLink| > Common.post_it(myLink) > } > else > sleep(1) > threads.each { |t| > unless t.status then > t.join > end > } > puts "total threads: " + Thread.list.size.to_s > redo > end > end > > threads.each { |t| t.join() } I can't speak for your supposed "leaks" (pure ruby almost never has leaks, but it does have many sneaky ways to make valid object references that you can overlook), since I can't figure out what your code does or how it is supposed to work. threads is an array of thread objects that you only ever push on and you never clear or shift off of. Also, why oh why oh why are you doing a redo??? Overly complicated code may not be the source of your leak (and in this case it may very well be), but it certainly isn't doing you any favors. I almost always structure my threads as a pool of workers pulling from a queue of tasks: > links = Queue.new > IO.read("bases/3+4.txt").split("\n").each do |l| > links << l > end > threads = [] > > 50.times do > threads << Thread.new do > until links.empty? do > Common.post_it links.shift > end > end > end > > threads.each { |t| t.join() }