[plt-scheme] Weak boxes and uncollected values

From: Eli Barzilay (eli at barzilay.org)
Date: Tue Jul 25 15:01:16 EDT 2006

On Jul 25, 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.
> 
> An example interaction with mzscheme:
> 
> > (define A (make-weak-box 'symbol))
> > (define B (make-weak-box (list 1 2 3)))
> > (define C (make-weak-box (+ 1 2 3)))
> > (define D (make-weak-box (not #f)))
> > (map weak-box-value (list A B C D))
> (symbol (1 2 3) 6 #t)
> > (collect-garbage)
> > (map weak-box-value (list A B C D))
> (#f #f 6 #t)
> 
> The symbol and list are collected; the fixnum and boolean are not.  Is
> this the intended behavior?  Is there a way to identify these values
> beforehand, so this behavior can be anticipated?

These are all unboxed values -- there's nothing that can be collected
since there is no `6' object.  I think that `#t' and `#f' are objects,
but they're always marked for no GCing.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!


Posted on the users mailing list.