Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!wuarchive!brutus.cs.uiuc.edu!apple!sun-barr!newstop!sun!pepper!cmcmanis From: cmcmanis%pepper@Sun.COM (Chuck McManis) Newsgroups: comp.sys.amiga Subject: Re: Is she c:Stack'd Message-ID: <125522@sun.Eng.Sun.COM> Date: 29 Sep 89 20:11:41 GMT References: <3944@m2-net.UUCP> Sender: news@sun.Eng.Sun.COM Reply-To: cmcmanis@sun.UUCP (Chuck McManis) Organization: Sun Microsystems, Mountain View Lines: 35 In article <3944@m2-net.UUCP> ba@m-net.UUCP (Bill Allen) writes: >What causes certain prgs to work just fine in 4K of stack >(or less) while others need 10K? I've seen several that >require 20K, 30K, 40K. Depends on what they put there. Some programs, like anything compiled with Lattice 5.x will adjust the stack when they start up, others just take what you give them. > Can other programming techniques be used to prevent this? Usually they can. A really common programmer error is to have a program that does something like : main() { unsigned char image1[640][200], image2[640][200]; ... } Or something equally innocent in appearance. What in fact happens is that these two arrays, being local to the main function, get allocated on the stack and that blow 256K of memory. Or even more common is a recursive function that has some fairly large number of local variables. Anyway those all eat up stack. > Is this "poor" programming or are there legitimate needs for > unavoidable minimum 60,000+ byte stack. There are legitimate reasons why you might need lots of stack space but I can't think of any off the top of my head :-). --Chuck McManis uucp: {anywhere}!sun!cmcmanis BIX: cmcmanis ARPAnet: cmcmanis@sun.com These opinions are my own and no one elses, but you knew that didn't you. "If I were driving a Macintosh, I'd have to stop before I could turn the wheel."