[Haskell-cafe] Re: Haskell maximum stack depth

Simon Marlow simonmarhaskell at gmail.com
Thu Feb 14 10:31:37 EST 2008


Adrian Hey wrote:

> I have no objection to people bounding their stack if that's their
> choice. I can't imagine why anybody who stopped to think about this
> would actually want this feature, but it's free world.
> 
> What I object to is it being bounded by default to something other
> than overall program memory limit.

(i'm a few days behind haskell-cafe, as usual...)

There *are* some good reasons to want a stack limit, but they are only 
practical concerns.

The point is, GHC has no such thing as the "overall program memory limit" 
unless by that you mean the total amount of memory + swap in your machine. 
  You can set a limit with +RTS -M, but there isn't one by default.  So 
what happens when you write a program with a space leak is that it gobbles 
up all the memory, and turns on the hard disk light for a few minutes until 
the OS gives up and kills it.  Or at least, you hope it kills your program 
and not something else important you were doing at the time.

We used to have a default heap limit, for the reason above, but I was 
persuaded to remove it because it was too much of a pain to keep having to 
say +RTS -M<whatever> when your program ran out of memory.  So we could do 
the same with the stack limit - the only concern is whether it will be 
highly inconvenient when we accidentally write programs with infinite 
loops, which in my experience seem to occur more than space-leaky programs.

We could also set the limit a lot higher than it currently is.  Or, we 
could try to figure out how much memory is in the machine and set it based 
on that.  Basically, I don't care that much, unless it means I have to do a 
lot of work to implement it :)

Cheers,
	Simon


More information about the Haskell-Cafe mailing list