From: Paganoni Date: 2009-04-02T16:19:40+09:00 Subject: Nilling for GC Hi, I've read that http://whytheluckystiff.net/articles/theFullyUpturnedBin.html. I have a background script that runs continuously and threads some tasks on demand. I keep track of the launched tasks but, by keeping those tracks, I certainly prevent tasks classes instances and threads instances to be discarded by the garbage collector. Data are stored like that : @workers[:one_category] = [] @workers[:one_category] << {:started_at => Time.now, :thread => th} So, I'm trying to setup a cleaner that would nil old references but I'm lost in maps : @semaphore.synchronize do @workers.map{|k,v| v.map{|worker| (Time.now - worker[:started_at] > 5 && worker[:thread].status == false) ? (cleaned +=1; nil) : worker}} end When condition is true, cleaned is incremented but the nil does not replace @workers entry. So, I did another test : hs = {} hs[:toto] = [] hs[:toto] << {:kk => 28, :so => 'yes'} hs[:toto] << {:kk => 30} hs[:tata] = [] hs[:tata] << {:kk => 2} hs = hs.map{|k,v| v.map {|a| a[:kk] > 28 ? nil : a} } pp hs displays [[{:kk=>28, :so=>"yes"}, nil], [{:kk=>2}]] This one works right, for each hs entry, array is nilled if :kk value is > to 28 Obviously there is a mistake somewhere in the first code source but I don't find it. Any help appreciated, thank you