[Haskell-cafe] Haskell maximum stack depth
Simon Peyton-Jones
simonpj at microsoft.com
Fri Feb 1 20:12:35 EST 2008
| Yes, using lots of stack is clearly bad with ghc, but this is a ghc
| "bug". In fact the only reason these programs do use lots of stack
| (vs. heap) is just a peculiarity of ghc rts implementation, so it
| really should be ghc that fixes the problem, or at least admits
| responsibility :-)
I don't think there's anything fundamental here. GHC allocates the stack in the heap, and it can grow as big as you like. The size limit is simply to catch infinite recursion with a more helpful message than "heap overflow". I think. There is one peculiarity though: I don't think we ever shrink the stack, so once it gets big it stays big. This could be fixed, though.
In short, feel free to set a very big max-stack size. If you are going to grow a stack of size N or a heap-allocated list of size N, the stack version will probably be more efficient -- with the caveat about deallocation that I mentioned.
Simon
More information about the Haskell-Cafe
mailing list