Determining and Setting the Stack's Size

Product Version(s): 3.3x
Operating System:   MS-DOS
Flags: ENDUSER | TAR52656
Last Modified: 22-FEB-1988    ArticleIdent: Q11220

Question:
   How do you determine the optimum stack size for a program, besides
using a trial and error method?
   How can we set the stack size?

Response:
   There is no direct and simple method to determine the needed stack
size. To get an estimate, do the following:

   1. Figure out the sequence of calls to functions made by the
program.
   2. From this, estimate the approximate size of your stack, using
the $symtab metacommand.
   3. Add a fudge factor of 10 percent plus 250 bytes.

   You may set the size of your program's stack at link time using the
/STACK switch. You may also use the /STACK option of the EXEMOD
utility. Note that the linker's stack switch accepts a decimal value
for the stack size, where the stack size stipulated using EXEMOD is in
hexadecimal.

