logo       

Re: Space leak: msg#00157

lang.haskell.glasgow.bugs

Subject: Re: Space leak

On Tue, Dec 27, 2005 at 08:12:20PM +0100, Christian Maeder wrote:
> Already the following bit exhibits unexpected memory consumption:
>
> main = mapM_ print $ take (n * 5) $ drop (n * 3) [1..]
> n = 100000
>
> Dropping the elements is more expensive than printing them. Somehow the
> dropped elements are kept in memory.

I think it's the (succ (succ (succ ...))) thunk. When you change it to
[1..99999999] there is no space leak - here every produced element must
be examined before producing the next list node or [].

Best regards
Tomasz

--
I am searching for a programmer who is good at least in some of
[Haskell, ML, C++, Linux, FreeBSD, math] for work in Warsaw, Poland


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise