[Haskell-cafe] how to debug stack overflow?

Johannes Waldmann waldmann at imn.htwk-leipzig.de
Sat Jun 22 16:36:34 CEST 2013

Aleksey Uymanov <s9gf4ult <at> gmail.com> writes:

> Try to use heap profiling. There is very high probability that the
> problem is because of space leak.

Really? Would it help in the standard example:

main = print $ foldr (+) 0 [1 .. 100000000::Int]

this leaks space (that is, cannot run in small space)
only because it leaks closures, right?
but how I'm going to recognize them in the heap profile?

When I run the above with +RTS -K1G -M1G -h -p
I do indeed get heap overflow (instead of stack overflow)
but the heap profile shows an allocation of 30k bytes only.

- J.W.

More information about the Haskell-Cafe mailing list