[MSLUG] Strange behaviour explained

Marc Feeley feeley at iro.umontreal.ca
Thu Aug 28 01:50:56 EDT 2008


For those who were there during my demo of "wills" at the MSLUG  
meeting...  the strange behaviour with collection of bignums has  
nothing to do with the reciprocal-cache (indeed it is correctly  
managed with a table with weak references), nor is it related to  
bignums.  It is really a byproduct of the recent result table which  
remembers the last 3 results of the REPL, so that they can be accessed  
with the forms # (last result), ## (penultimate result) and ###.  In  
the example below the bignum 1000000000000000000000000000000 which was  
reachable through variable "a" is still reachable after the (set! a  
#f) because it is still in the recent result table.  A few dummy  
expressions have to be entered so that bignum is dropped from the table.

I remember feeling uncomfortable when introducing the REPL recent  
result history because of the temporary space leak. Now I know why...

Marc


Gambit v4.2.8

 > (define a (expt 10 30))
 > (make-will a (lambda (x) (pp (list 'died: x))))
#<will #2>
 > a
1000000000000000000000000000000
 > (set! a #f)
 > (##gc)
 > (##gc)
 > 111
111
 > 222
222
 > 333
333
 > (##gc)
(died: 1000000000000000000000000000000)



More information about the MSLUG mailing list