next up previous contents index
Next: Finalization Up: Garbage Collection in the Prop Library Previous: The Bartlett style mostly

The Mark Sweep collector

An alternative to the copying collector is the the mark sweep collector. Like the previous collector, this collector also uses conservative scanning to locate roots. Unlikely the Boehm collector, type accurate marking is used through the user supplied tracing method.

Since the default collector is of the BGC variety, the user must create an instance of MarkSweepGC if the mark sweep collector is to be used.

   class MarkSweepGC : public CGC {
   public:
      virtual void set_gc_ratio(int);
      virtual void set_initial_heap_size (size_t);
      virtual void set_min_heap_growth   (size_t);
   }

The gc ratio in class MarkSweepGC determines whether heap expansion is to be performed after a collection. The default gc ratio is 50%, thus if after garbage collection the ratio of used versus total heap space exceeds one half, the heap will be expanded.

For most purposes the two collectors are interchangeable. Since all types of garbage collectors under our framework use the same protocol, applications can be written without fixing a specific garbage collection algorithm before hand.



Allen Leung
Mon Apr 7 14:33:55 EDT 1997