[Haskell-cafe] Stack, Heap and GHC

Felix Breuer felix at fbreuer.de
Thu Dec 14 10:00:53 EST 2006


Hello everyone,

I have been trying to run a Haskell program of mine that does an
extensive computation with very large amounts of data. I compiled the
program with ghc --make. When I run it it terminates after some time
with the message:

  Stack space overflow: current size 8388608 bytes.
  Use `+RTS -Ksize' to increase it.

The program isn't that well written so the overflow did not surprise me,
I expected that it might run out of memory. What did surprise me was the
*stack* overflow. I do not use recursion in my program except for a
couple of fold operations over very large lists. So I have a number of
questions:

1) Which Haskell operations cost space on the stack, which cost space on
the heap? I guess this is implementation dependent, so I looked into the
GHC manual but did not find an answer. Where can I look these things up?

2) What could be possible sources of a stack overflow? (Apart from a
recursive but not tail-recursive function.)

3) I tried using +RTS -K<size> as suggested, but these options do not
seem to be passed through if I use --make. How can I use both, these
compilation flags and --make?


Thanks,
Felix




More information about the Haskell-Cafe mailing list