Ken Anderson wrote:
To: "SourceForge.net" <noreply@xxxxxxxxxxxxxxx>
Subject: Re: [SISC-devel] [ sisc-Bugs-1091312 ] java.lang.OutOfMemoryError:
Java heap space
Cc: noreply@xxxxxxxxxxxxxxx
The out of memory occurs because of how SICP does laziness.
See http://srfi.schemers.org/srfi-45/srfi-45.html
Ken,
that's what I thought at first too but the problem turns out to be with
the memo-proc procedure in the example. If it is changed to not remember
the proc once it has been used, e.g.
(define (memo-proc proc)
(let ((result #f))
(lambda ()
(if proc
(begin (set! result (proc))
(set! proc #f)))
result)))
then the code runs in near-constant space. SISC's general
safe-for-spaceness may be one reason why that works - the compiler does
capture analysis that guarantees that code does not hang on to
references any longer than strictly necessary.
Matthias.
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
|