[comp.sys.mac.programmer] How do you expand the stack?

jrk@sys.uea.ac.uk (Richard Kennaway) (02/21/90)

How do you change the stack size of a Mac application?  The default is
only 8k, and I have a program that needs much more.  I havent found any
explicit description in IM or the TNs; all I can find is the description
in the Memory Manager chapter of IM vol2 of GetApplLimit and
SetApplLimit.  From that it appears that this should do it:

void GetMoreStack( extraStack )
long extraStack;	/* long = 32 bits */
{
Ptr heapLimit;

    heapLimit = GetApplLimit();
    if (extraStack > 0) SetApplLimit( heapLimit - extraStack );
}

This is the very first thing the application does.  Is this the right
way?  If not, what is?

I am having the problem that the program intermittently crashes when
starting up, which suggests some bad memory access.  It didnt happen
before I added the call to the above routine.  I've made other
changes as well, so it may be something else, but I'd like to at least
get confirmation that this part is ok.  When it does run, it seems to
get the extra stack space (i.e. it no longer gets the stack-has-collided-
with-heap bomb).

MPW C version 3, System 6.0.4, MultiFinder 6.1b7, a zillion inits, but
they all work with everything else.

--
Richard Kennaway          SYS, University of East Anglia, Norwich, U.K.
Internet:  jrk@sys.uea.ac.uk		uucp:  ...mcvax!ukc!uea-sys!jrk

ml10+@andrew.cmu.edu (Michael A. Libes) (02/23/90)

> How do you change the stack size of a Mac application?  The default is
> only 8k, and I have a program that needs much more.  I havent found any

Actually, the standard stack size on the Mac +/SE is 8K, but the
standard stack on Mac II/x,cx,ci is 24K.

    - luni

olson@bootsie.UUCP (Eric Olson) (02/24/90)

In article <kZt2S6O00WBME1vXAx@andrew.cmu.edu> ml10+@andrew.cmu.edu (Michael A. Libes) writes:
>
>Actually, the standard stack size on the Mac +/SE is 8K, but the
>standard stack on Mac II/x,cx,ci is 24K.

I thought that the stack grew from the top of memory (or MF partition), while the
heap grows from the bottom (and when they collide, you get System Bomb 28).
Did this change?  Or is the "stack size" the _minimum_ stack size, like
you would get if you called MaxApplZone to grow the heap as big as possible?

-Eric
Please note!  olson@bootsie.uucp will not work!  Use an address below:

Eric K. Olson                 Internet:   olson@endor.harvard.edu
Lexington Software Design     Usenet:     harvard!endor!olson
72A Lowell St.                Applelink:  olson@endor.harvard.edu@dasnet#
Lexington, MA  02173          Compuserve: >INTERNET:olson@endor.harvard.edu
(617) 863-9624                Bitnet:     OLSON@HARVARD