[Haskell-beginners] what space leak could happen here?

Brandon Allbery allbery.b at gmail.com
Mon Sep 22 04:19:19 UTC 2014


On Mon, Sep 22, 2014 at 12:10 AM, Phil Xiaojun Hu <phil at cnphil.com> wrote:

> Think of a network socket as the source of your list, and the first
> character is all you need. If you need to evaluate the second character
> to get the first, you could be stuck on the network socket for some
> time waiting for the second one to come.
>

That's more of a time leak. I think the space leak aspect comes from the
fact that you've evaluated a second list element that was not requested,
may never be used, and will be held in the heap until all shared consumers
of the list go out of scope. (It may of course also be a time leak if
computing that second element is expensive.)

-- 
brandon s allbery kf8nh                               sine nomine associates
allbery.b at gmail.com                                  ballbery at sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20140922/ac44bccc/attachment.html>


More information about the Beginners mailing list