From: Florian Frank Date: 2009-11-10T07:02:37+09:00 Subject: Re: Good or best way to allocate a large array 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. > Except that uses aren't counted in Ruby. Ruby has a mark-and-sweep garbage collector. When Ruby runs out of memory a garbage collection run is triggered. If there aren't any references to the objects in question left, they aren't reachable from the root set and thus not marked in the first phase of GC, in the second phase they will then (too be conservative: most likely) be freed. -- Florian Frank