From: Ralph Shnelvar Date: 2009-11-10T07:46:33+09:00 Subject: Re: Good or best way to allocate a large array Florian, If there is no use count, how does Ruby know that there are no references to the object that should be freed? Ralph Monday, November 9, 2009, 3:02:37 PM, you wrote: FF> Ralph Shnelvar wrote: >> Marnen, >> >> Unless "scope" means something different in Ruby than it does in other >> languages, it would appear that the garbage collector cannot possibly >> free memory when something goes out of scope but, instead, when the >> UseCount goes to zero. >> FF> Except that uses aren't counted in Ruby. Ruby has a mark-and-sweep FF> garbage collector. When Ruby runs out of memory a garbage collection run FF> is triggered. If there aren't any references to the objects in question FF> left, they aren't reachable from the root set and thus not marked in the FF> first phase of GC, in the second phase they will then (too be FF> conservative: most likely) be freed. -- Best regards, Ralph mailto:ralphs@dos32.com