A couple garbage collector questions

David Bolen db3l at fitlinxx.com
Fri Apr 6 00:01:17 EDT 2001


Skip Montanaro <skip at pobox.com> writes:

>     >>> Reference-counting exacts very heavy performance costs, no matter
>     >>> what you back it up with.
> 
>     Hannah> Correct. *Except* if the compiler does heavy optimization of
>     Hannah> reference count updates (i.e. if you can prove that some basic
>     Hannah> block just increases the RC, later decreases it, having a net
>     Hannah> effect of +- 0, you can drop both RC updates, and so on).
> 
> This is unlikely to happen in practice.  A basic block consists of a
> straightline piece of code containing no branches.  There's no reason to
> increment a reference count and decrement it within the same basic block,
> since the object's reference count can't be decremented to zero by some
> other piece of code.

Not only that, but the basic block has to be atomic in a
multi-threaded environment.  Otherwise, some other thread may gain
control and release the last reference to an object that is being used
within the "basic block" but wasn't marked as such, and the object may
be reclaimed before the original block gets control again.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list