chicken-users
[Top][All Lists]
Advanced

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

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


From: Moritz Heidkamp
Subject: Re: [Chicken-users] Strange memory leak with lazy-seq
Date: Tue, 24 Feb 2015 11:17:29 +0100

Hi Alex,

On 24 February 2015 00:13 CET, Alex Shinn wrote:

> 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.

Kooda and I discussed this issue on IRC yesterday and in fact, the first
version doesn't leak when compiled either (he mixed up results when
writing this email). So either the CHICKEN compiler is the first Scheme
implementation to not leak memory in this case or something else is
going on :-)

Note that lazy-seq doesn't actually use delay / force internally but a
custom implementation because up until
http://code.call-cc.org/cgi-bin/gitweb.cgi?p=chicken-core.git;a=commit;h=9079b9b7ab57f296c9e3bf9f9cd42b1bad1a6baf
CHICKEN promises would consume more and potentially leak memory as they
didn't free the promise closure after realization.

So as it stands, the leak only seems to occur in the interpreter. We
also found that replacing `void' with `(lambda (_) (gc))' makes the leak
go away when interpreted, too. Seems like there's some difference with
how garbage collection is triggered compared to compiled code.

Thanks for your input!

Moritz



reply via email to

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