Reference counting

John M McIntosh johnmci at ibm.net
Wed Oct 27 06:11:16 UTC 1999


> On Tue, 26 Oct 1999 14:01:24   John Duncan wrote:
> 
>>>Is that right?  I was under the impression that
>>>the object isn't purged until the gc occurs.
>>>[Indeed, what is described is something more like
>>>reference counting than gc].  Further, can't you
>>>register objects for finalization, thus giving
>>>each object a chance to say "I want to stay?" or
>>>to copy itself somewhere -- or would that action
>>>be beyond the scope of a valid finalization
>>>action?

> John, I recommend a careful look at the extensive work
> done for Eiffel's memory reclamation and the issues
> involved, in
> <a href="http://www.eiffel.com/doc/oosc/page.html">OOSC-2</a>,
>  about pages 304-314.  Also, we're fortunate that a
> lot of this stuff
> <a
href="http://www.eiffel.com/doc/manuals/technology/internal/gc/page.html">is
>  online</a>, too.

I'll also chip in and say you can find lots more on GC theory at my site, in
papers and presentations.

As pointed out one of the strange things that one can do in some flavors of
Smalltalk is take back an about to be GCed object. As part of finalization
you can make a strong reference and effectively forbid the GCing of the
object. Mind you it makes my head hurt why you would want to do this!

Regarding Latency, an example. Given this simplified code

thing isAnOrange ifTrue: [Transcript show: thing color]

Many times I've seen a walkback, nil does not understand color, but what
happened, how could thing which just responded to the isAnOrange message
become nil? Well a GC occur and thing just well disappeared.

A few years back if I recall I believe VisualAge 2.x only finalized one
object per GC pass. Create a few thousand weak objects and GC them, then
this took a long time. If you were dependent on having the finalization
occur shortly after the object was destroyed, then you were in for a
surprise.

--
===========================================================================
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
===========================================================================
Custom Macintosh programming & various Smalltalk dialects
PGP Key: DSS/Diff/46FC3BE6
Fingerprint=B22F 7D67 92B7 5D52 72D7  E94A EE69 2D21 46FC 3BE6
===========================================================================





More information about the Squeak-dev mailing list