[gambit-list] small garbage collection issue?

Christian christian at pflanze.mine.nu
Mon Nov 28 18:07:00 EST 2005


Hello

I've noticed that gambc40b14 and gambc40b15 don't collect memory while
evaluating this statement in the repl (this is using chjmodule -- ask
me if you want a smaller test case):

> (build-recursively/import 'cj-stream)
> (stream-length (stream-iota))
*** ERROR IN ##cons -- Heap overflow
1> 

stream-iota creates an infinite lazily evaluated list, so the above is
of course essentially an endless loop. Since the head of the stream is
not stored anywhere, I expected it to be garbage collected. In fact,
the following all work as expected:

> (define (f) (stream-length (stream-iota)))
> (f)
;;runs forever

> (time (stream-length (stream-iota)))
;;runs forever

I don't know whether the behaviour of the first case might lead to a
problem relevant in practice. Note that leaving the exception handler
and running (##gc) still reclaims the space allocated in that case.

Christian.




More information about the Gambit-list mailing list