[plt-scheme] Re: Puzzle about amb and memory

From: Matthias Felleisen (matthias at ccs.neu.edu)
Date: Tue Apr 1 13:33:19 EDT 2008

amb subexpressions can't be in tail position. After spawning the  
threads you have to monitor them, returning the first value either  
one of the produces.


On Apr 1, 2008, at 1:22 PM, Danny Yoo wrote:
>> I think the crux of the problem is that your test-1 creates 7
>> continuations, and test-2 creates 70 continuations.  Apparently, 70
>> continuations is enough to cause PLT Scheme to segfault, but 7 isn't.
>
>
> Hi Mark,
>
> But just creating continuations isn't going to exhaust memory,  
> unless those continuations can't be garbage collected.  For example:
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> #lang scheme/base
> ;; infinite loop through call/cc
> (define (inf)
>   (define top #f)
>   (let/cc k
>     (set! top k))
>   (let/cc k2
>     (top)))
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> runs perfectly well in bounded space even though it's busily  
> creating k2 continuations like mad.
>
>
> My assumptions right now are that either the recursion either isn't  
> tail, or the continuations aren't getting collected.  I've pored at  
> the amb source code a bit, but I don't see yet anything wrong with  
> regards to tail calls.
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme



Posted on the users mailing list.