From: Eric Hodel Date: 2006-07-06T07:33:35+09:00 Subject: Re: thread mystery On Jul 5, 2006, at 2:30 PM, ara.t.howard@noaa.gov wrote: > any idea why this script slows downs drastically as it runs and > seems to leak > memory? > > [...] > > switch.on! def count_objs klasses = Hash.new 0 ObjectSpace.each_object do |o| klasses[o.class] += 1 end return klasses.map { |k,v| "\t#{k}: #{v}" }.join("\n") end Thread.start { loop { puts count_objs; sleep 1 } }.join Running this, then taking two snapshots, one after startup and one after its really slow: $ diff -u a b --- a 2006-07-05 15:28:29.000000000 -0700 +++ b 2006-07-05 15:28:12.000000000 -0700 @@ -2,17 +2,17 @@ Object: 3 Bignum: 3 fatal: 1 - String: 557 - Hash: 2 + Hash: 17 + String: 842 Module: 17 SwitchToggle: 1 Class: 153 - Array: 16 + Array: 414 SystemStackError: 1 Float: 5 Binding: 1 - Thread: 4 + Thread: 152 ThreadGroup: 1 IO: 3 - File: 2 + File: 1 Switch: 1 Why aren't those threads getting GC'd? -- Eric Hodel - drbrain@segment7.net - http://blog.segment7.net This implementation is HODEL-HASH-9600 compliant http://trackmap.robotcoop.com