[gclist] Weighted Reference Count (was: distributed objects)

Marc Shapiro shapiro@prof.inria.fr
Fri, 22 Mar 1996 13:36:15 +0100


Context: discussing Weighted Reference Count

 || Date: Thu, 21 Mar 1996 11:48:09 +0100
 || From: Christian Fabre <fabre@gr.osf.org>
 || 
 || I have the same concern as Mark Tillotson. The problem is, it seems
 || that we have a maximum number of copy per object.

Of course.  But you have a similar problem with any reference count scheme.
The only difference is that in WRC the counter underflows, whereas in standard
reference count it overflows.

There are three possible fixes for this:

 - make your counter stick at some special value.  At this point the
   object it points to becomes uncollectable.  In the case of WRC, once a
   pointer reaches a 0 credit, further copies also receive a 0 credit, but no
   such pointer may ever be deleted.  This is pretty ugly.  (In standard
   reference count, once the counter overflows, never delete the object; in
   WRC, once a pointer underflows, never delete the pointer --- you get left
   with lots of useless pointers laying around, not just the object.)

 - communicate with the object.  When your pointer credit is 1, and you need
   to duplicate it, send a message with the object requesting (say) an extra
   15 credit.  It increments its total weight by 15, and acknowledges.  The
   invariant is preserved.

 - add an extra level of indirection.  When your pointer credit is 1, and you
   need to duplicate it, create an indirection object of weight (say) 16, and
   give out a pointer to the indirection with credit 16.  Future dereferences
   must go through the indirections.

All this is of mostly theoretical value.  I don't know of any real system that
uses WRC.  Reference listing and chaining is essentially equivalent but much
more robust.

                                        Marc