Memory leak
From HaskellWiki
A memory leak means that a program allocates more memory than necessary for its execution. Although Haskell implementations use garbage collectors, programmers must still keep memory management in mind. A garbage collector can reliably prevent dangling pointers, but it is easily possible to produce memory leaks, especially in connection with lazy evaluation.
Consider for example:
let xs = [1..1000000::Integer] in sum xs * product xs
let
xs
sum
product
xs
xs
xs
Since we want to avoid code duplication, we like to achieve this by turning the list definition into a function with a dummy argument.
let makeXs _ = [1..1000000::Integer] in sum (makeXs False) * product (makeXs True)
