Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!tank!eecae!cps3xx!usenet From: usenet@cps3xx.UUCP (Usenet file owner) Newsgroups: comp.sys.amiga Subject: Re: Is she c:Stack'd Message-ID: <4837@cps3xx.UUCP> Date: 3 Oct 89 18:02:33 GMT References: <3944@m2-net.UUCP> <8053@cbmvax.UUCP> <19086@ut-emx.UUCP> <620@nigel.udel.EDU> Reply-To: porkka@frith.UUCP (Joe Porkka) Organization: Michigan State University Lines: 36 In article <620@nigel.udel.EDU> new@udel.edu (Darren New) writes: >way to cut stack usage. However, it usually isn't >worth it unless you can cut the stack size >down to where the program will run with the default >stack size (4K, I think), as the user will have to >set the stack anyway. Usually the run-time routines and >the OS and libraries and ... will use some stack too, >but I don't remember how much; usually a few hundred >bytes is enuf for well-designed libraries. The secret is >to calculate and KNOW how much stack you need. Probly the best way is for the CLI to set the stack like the Workbench does..... What I do for my own programs is have them set the stack themselves. I use the technique by Werner Guenther (not sure about spelling) to detach from the CLI by splitting the first segment away from the rest, then do a CreateProc and have it set the stack size this way. How do I know how much stack? (This works well for non-recursive, or limited recursion) In the startup code (in the slipt off part) the first thing it does is clear the stack to a constant (non-zero). It then calls _main, and then counts the number of bytes on the stack still containing that pattern, and prints out info about stack usage. This is for development only. Once the program is 'finished', then remove or disable the stack counting stuff. ( i simply use a cmd line arg "debug" to turn it on when I want). For this to work proerly the program must be taken trough all its functions, or at least the deepest (procedural wise) functions. REAL NAME: Joe Porkka porkka@frith.egr.msu.edu