[Haskell-cafe] Re: Laziness leaks

apfelmus apfelmus at quantentunnel.de
Thu Jun 5 08:06:26 EDT 2008

Ketil Malde wrote:
> I the meaning of "leak" is in a bit of flux.  Originally, I believe 
> it refers to a memory leak, where the programmer forgot to call 
> free() before losing the pointer, thus making the program consume 
> memory it can't recover, and can't use.
> With automatic memory management, this doesn't happen, so "memory 
> leak" then started to mean retaining objects longer than necessary.

I agree. This definition fits the "space leak"

   foldl (+1) 0 [1..10000]   ->  (((...)+1)+1)

in the sense that the unevaluated expressions are retained in memory
longer than necessary; the difference being of course that it's not
garbage collection but beta-reduction that frees the memory in question.

On the other hand, I think that the situation of

   foldl (+1) 0 [1..10000]

in a strict language does not fit this definition of leak because
evaluating the list [1..10000] eagerly does not retain memory longer
than necessary, it consumes memory earlier than necessary.

So, this notion of leak is spot-on.

> I'm not sure I'll use terms like strictness and laziness leak, I 
> think it's hard to see what's being lost here, and if you have a 
> laziness leak, it is unclear if it's too much laziness or too little?

Me too, I don't see a reason to muddy the word with other meanings.
"Space leak" is a good word in the sense that "space" describes the
"leak"; it's the space that leaks and goes down the drain. Neither
laziness nor strictness can leak and be washed away with the rain.

> (Aside: am I the only one who is shocked by the memory consumption of
>  modern programs?  I use a simple time tracker (gnotime), a calendar
>  with a handful of entries (evolution), and they both typically 
> consume half to one gigabyte of memory.  In all fairness, it seems to
>  be much better under Ubuntu 8.04 than 7.10, but again, they haven't 
> been running for very long yet.)

Yeah :( When a piece of softwares wastes time and memory, they should
have written it in Haskell, so that at least the other bugs wouldn't
plague me as well.


More information about the Haskell-Cafe mailing list