profiling for stack usage

Ketil Z. Malde
15 Aug 2003 17:21:33 +0200

Hi again,

I'm currently in a situation where my program runs easily out of
stack.  Depending on the input, stack usage often exceeds 10Mb.

1. Is there a way to profile stack usage, so that I can identify the
culprit and deal with the problem at the root?  Normal (time)
profiling tells me how many times a function is called, but it would
be interesting to know how many times it was recursively called, or
the size of its stack frames.  Is that information available?

Heap profiling -- well, it doesn't *sound* as if it would incorporate
the stack; does it anyway?

2. Is there a way to compile programs to use more than the default
stack?  I can of course pass +RTS -K10M -RTS on the command line, but
I would rather like to change the default, instead of kicking myself
for forgetting it all the time.  And is there any reason (except
excessive resource consumption and postponed failure from infinite
loops) not to run with huge stacks? 

If I haven't seen further, it is by standing in the footprints of giants