From: Rick DeNatale Date: 2009-11-13T00:30:00+09:00 Subject: Re: Good or best way to allocate a large array On Thu, Nov 12, 2009 at 10:05 AM, Simon Krahnke wrote: > * Rick DeNatale (2009-11-10) schrieb: > >> Mark/Sweep is a fairly primitive GC technique, it was probably the >> second technique applied in the long history of GC.  There are more >> recent techniques such as generation scavenging which makes use of the >> observance that most objects in a uniformly object-oriented language >> like Ruby either live a very short, or a reasonably long life time >> with the preponderance being short-lived. Generation scavenging >> collects the short-lived objects very efficiently, and typically uses >> mark-sweep less frequently to clean up the older ones. > > In my understanding these are orthogonal concepts. How to find out what > to collect, and how to do the collection. > > Mark and sweep is a technique to find collectable objects just like > reference counting. And a copying gc (like a generational) is a > way of collecting these objects, more efficient than calling free(). No, a copying GC doesn't substitute for the sweep phase of mark and sweep. Instead it works by tracking references to new objects from old objects, and copying live objects to a new generation space, leaving new objects which are not reachable behind. After an object has survived a number of such scavenging cycles it gets moved to old space which is then usually gc'd using another method such as mark and sweep. A copying GC does a bit of marking via a write barrier which notes when a reference to a 'young' object has been stored in an 'old' object, and combines the traversal of the young object space with collection by moving surviving objects. It's efficient because the overhead of eliminating young dead objects is quite a bit lower, and typically there is a lot of infant mortality in a highly object oriented system. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Twitter: http://twitter.com/RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale