Space leak

Tomasz Zielonka tomasz.zielonka at gmail.com
Wed Dec 28 02:12:33 EST 2005


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



More information about the Glasgow-haskell-bugs mailing list