From: MenTaLguY Date: 2008-01-09T08:45:34+09:00 Subject: Re: Manual Memory Management On Tue, 8 Jan 2008 14:35:28 +0900, Marcin Raczkowski wrote: > I had idea of reference counting GC for a moment, I'm not sure how hard > it would be to implement and if it's actually usable. Perl has a reference-counting GC without cycle-detection (except on thread termination), as does TCL (though it isn't really possible to create real GC cycles in TCL anyway). Python has a reference-counting GC with cycle detection. Microsoft's JScript (JavaScript) is also purely reference-counted. So it's certainly done in practice. However, more mature garbage-collected languages (i.e. smalltalk, lisp dialects, java, other JavaScript implementations, etc.) with garbage collection almost universally use some variant of mark-and-sweep instead. There are a lot of reasons for this, including nice handling of reference cycles (Microsoft's JavaScript implementation is notorious for memory leaks) and minimal overhead for common reference operations. Generally the amortized cost of mark-and-sweep is lower too. I think the real problem that needs to be addressed is that Ruby's mark-and-sweep implementation is not actually very good, in terms of heap sizing/reclaimation and collection heuristics. -mental