home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / programm / 14933 < prev    next >
Encoding:
Text File  |  1992-09-03  |  1.8 KB  |  58 lines

  1. Newsgroups: comp.sys.mac.programmer
  2. Path: sparky!uunet!cs.utexas.edu!torn!newshost.uwo.ca!uwovax.uwo.ca!tschneid
  3. From: tschneid@uwovax.uwo.ca
  4. Subject: SUMMARY: increasing stack size
  5. Organization: University of Western Ont, London
  6. Date: Thu, 3 Sep 1992 13:31:27 GMT
  7. Message-ID: <1992Sep3.093127.1@uwovax.uwo.ca>
  8. Followup-To: comp.sys.mac.programmer
  9. References: <1992Sep1.145611.1@uwovax.uwo.ca> <ksand-010992171044@wintermute.apple.com>
  10. Sender: news@julian.uwo.ca (USENET News System)
  11. Nntp-Posting-Host: hydra.uwo.ca
  12. Lines: 44
  13.  
  14. In article <ksand-010992171044@wintermute.apple.com>, ksand@apple.com (Kent Sandvik) writes:
  15. > In article <1992Sep1.145611.1@uwovax.uwo.ca>, tschneid@uwovax.uwo.ca wrote
  16. >> 
  17.  
  18. [ my original incorrect code (complete with stupid error!) ]
  19. >> 
  20. >>         newapplimit = 300*1024;    /* give app 300k */
  21. >>         SetApplLimit(ApplLimit()+newapplimit);
  22. >>         MaxApplLimit();
  23. >> 
  24. >> Unfortunately, this does not work ...
  25. > In what way, collision of stack and heap (more memory required then)?
  26. > Other problems?
  27.  
  28. I was getting stack and heap collisions (System Error #33 ... or was it #15
  29. ... it was rather late that)
  30.  
  31. Thanks to everyone who replied (John, Larry, Grobbins, Mike [thanks for the
  32. code!], Duane, Dave and Kent). Once my original mistake was pointed out ...
  33. the stack grows down from high memory (not up) ... and I saw some sample
  34. code, I arrived at the following solution:
  35.  
  36.     /* put this immediately after main() */
  37.     #define NEW_STACK_SIZE    32768    /* 32k stack */
  38.     #define OLD_STACK_SIZE    8192    /* I own a lowly Mac Plus */
  39.  
  40.     SetApplLimit(ApplLimit - (NEW_STACK_SIZE - OLD_STACK_SIZE));
  41.     MaxApplZone();
  42.  
  43.     /* check */
  44.     printf("Stack size: %ld\n",StackSize()); /* should be around 32k */
  45.     printf("Max. Memory: %ld\n",MaxMem(0L));
  46.  
  47. This has eliminated the stack/heap collisions that were causing regular
  48. crashes.
  49.  
  50. Thanks again,
  51. Todd.
  52.  
  53.  
  54.  
  55. > Kent Sandvik/DTS
  56.