[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Strange memory leak with lazy-seq

From: Alex Shinn
Subject: Re: [Chicken-users] Strange memory leak with lazy-seq
Date: Tue, 24 Feb 2015 08:13:02 +0900

On Mon, Feb 23, 2015 at 9:57 PM, Kooda <address@hidden> wrote:

I’ve been playing with lazy-seq for the past few days and found a very
strange behaviour:

The heap of the following program keeps growing rapidly in csi, running
the same program after compilation seems to slow down the growth quite a
lot but the heap isn’t constant as I was expecting it to be.

Here is a test case of the problem:

; Start this script with `csi -:D -:hi100k -:hg101` to observe heap resizing

(use lazy-seq)

(define (complex-stream seq)
  (lazy-map identity seq))

; This seems to leak:
(lazy-each void (complex-stream (lazy-numbers)))

; This doesn't:
#;(lazy-each void (lazy-map identity

You may be falling short of the issue described by SRFI 45,
which is that in all known Scheme implementations:

  (define (loop) (delay (force (loop))))
  (force (loop))

leaks memory.  In R7RS this becomes

  (define (loop) (delay-force (loop)))

which is required by the standard not to leak.

I'm not sure why you don't observe a leak in the
second example.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]