[Haskell-cafe] Re: Haskell maximum stack depth

Simon Marlow simonmarhaskell at gmail.com
Thu Feb 14 09:15:07 EST 2008

Stefan O'Rear wrote:
> On Mon, Feb 04, 2008 at 10:13:12PM +0000, Adrian Hey wrote:
>>> Also
>>> remember that this behaviour never wastes more than 50% of the stack,
>>> which is a relatively small amount.
>> Only if the stack is relatively small. Would you say the same about
>> heap, or about a stack that only needed 50% of heap space but ended
>> up using all of it? Or money? Using twice as much as you need of
>> anything is bad IMO.
> Apparently you don't realize that GHC normally uses twice as much heap
> as is needed, due to the decision to use a two-space copying collector
> by default for the oldest generation. :)

Three times in fact, on average.

If the old generation contained L live data at the last collection, it is 
allowed to grow to 2L before being collected again.  If it still has L live 
data at the next collection, L is copied, giving you a total requirement of 
3L for a major collection.  Compacting GC reduces this to 2L, because the 
live data is not copied.

The factor of 2 is tunable using +RTS -F.


More information about the Haskell-Cafe mailing list