[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: stack size



"C. Ahlstrom" <ahlstromc@bellsouth.net> writes:

> ++++++++ Lennart Sorensen 09:32 Wed 23 Apr      ++++++++
>
>>On Tue, Apr 22, 2008 at 11:57:35PM -0700, Francesco Pietra wrote:
>>>
>>> >From that, I extrapolated (now clearly wrongly) that setting stack
>>> >size to unlimited may be beneficial to have all available memory
>>> >used in memory-demanding computation.
>>
>>Well the stack is only used for passing arguments to functions and for
>>local variables in a function.  Most large chunks of data are allocated
>>using malloc which means it comes from the heap, not the stack.
>>
>>It takes a rather badly designed program to use 8MB of stack space.
>
> I've seen that in geographical information software (GIS), too.
> Something like 32Mb of stack needed.
>
> But when you think about it, isn't stack easier to maintain?  <grin>

On the other hand it has to be written by the caller and read by the
callee. If you have that much data to pass along do you really want to
copy it around all the time? Why not pass a pointer to it and be that
much quicker.

Unless you really do have a recursive depth >200 in the code, in which
case you might want to think about rewriting that iteratively. Just
saving the stack frame creation can save you time at that depth.

In summary: "It takes a rather badly designed program to use 8MB of
stack space." (see above :)

MfG
        Goswin


Reply to: