[plt-scheme] Weak boxes and uncollected values

From: Robby Findler (robby at cs.uchicago.edu)
Date: Tue Jul 25 18:01:33 EDT 2006

At Tue, 25 Jul 2006 15:28:13 -0400, "Carl Eastlund" wrote:
> On 7/25/06, Matthew Flatt <mflatt at cs.utah.edu> wrote:
> > At Tue, 25 Jul 2006 15:05:51 -0400, "Carl Eastlund" wrote:
> > > > > Certain values, such as #t and fixnum integers, don't "vanish" from
> > > > > weak boxes after garbage collection, even when there don't seem to be
> > > > > any outside references.
> >
> > There are still references somewhere. In particular, if you read `#t',
> > you get back an object that is `eq?' to the key in the hash table.
> > That's true for `7', too, if you use 7 as a key.
> >
> > Since you can still reach the key, the mapping stays in the hash table.
> 
> Are you trying to tell me mzscheme keeps around a reference to every
> fixnum the program ever generates, just in case it might happen to
> compute the same number again?  I don't believe you, or I'm seriously
> misunderstanding your statement.

In the lower-level world of one enourmous array where all values are
references into that array, it turns out that the odd-numbered
references aren't actually legal references (it's a strange world down
there :) so the bit pattern for the scheme fixnum 8 is 00...010001
(with some number of 0s in the ellipses), but there is no heap storage
associated with this.

So, one way to think of this situation is that the fixnum *is* the
reference. There's no difference.

Robby



Posted on the users mailing list.