home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.programmer
- Path: sparky!uunet!cs.utexas.edu!torn!newshost.uwo.ca!uwovax.uwo.ca!tschneid
- From: tschneid@uwovax.uwo.ca
- Subject: SUMMARY: increasing stack size
- Organization: University of Western Ont, London
- Date: Thu, 3 Sep 1992 13:31:27 GMT
- Message-ID: <1992Sep3.093127.1@uwovax.uwo.ca>
- Followup-To: comp.sys.mac.programmer
- References: <1992Sep1.145611.1@uwovax.uwo.ca> <ksand-010992171044@wintermute.apple.com>
- Sender: news@julian.uwo.ca (USENET News System)
- Nntp-Posting-Host: hydra.uwo.ca
- Lines: 44
-
- In article <ksand-010992171044@wintermute.apple.com>, ksand@apple.com (Kent Sandvik) writes:
- > In article <1992Sep1.145611.1@uwovax.uwo.ca>, tschneid@uwovax.uwo.ca wrote
- >>
-
- [ my original incorrect code (complete with stupid error!) ]
- >>
- >> newapplimit = 300*1024; /* give app 300k */
- >> SetApplLimit(ApplLimit()+newapplimit);
- >> MaxApplLimit();
- >>
- >> Unfortunately, this does not work ...
- >
- > In what way, collision of stack and heap (more memory required then)?
- > Other problems?
-
- I was getting stack and heap collisions (System Error #33 ... or was it #15
- ... it was rather late that)
-
- Thanks to everyone who replied (John, Larry, Grobbins, Mike [thanks for the
- code!], Duane, Dave and Kent). Once my original mistake was pointed out ...
- the stack grows down from high memory (not up) ... and I saw some sample
- code, I arrived at the following solution:
-
- /* put this immediately after main() */
- #define NEW_STACK_SIZE 32768 /* 32k stack */
- #define OLD_STACK_SIZE 8192 /* I own a lowly Mac Plus */
-
- SetApplLimit(ApplLimit - (NEW_STACK_SIZE - OLD_STACK_SIZE));
- MaxApplZone();
-
- /* check */
- printf("Stack size: %ld\n",StackSize()); /* should be around 32k */
- printf("Max. Memory: %ld\n",MaxMem(0L));
-
- This has eliminated the stack/heap collisions that were causing regular
- crashes.
-
- Thanks again,
- Todd.
-
-
-
- >
- > Kent Sandvik/DTS
-