Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!cs.utexas.edu!usc!apple!stevec From: stevec@Apple.COM (Steve Christensen) Newsgroups: comp.sys.mac.programmer Subject: Re: Memory management problem Message-ID: <9780@goofy.Apple.COM> Date: 15 Aug 90 21:34:37 GMT References: <1990Aug15.154812.9145@IRO.UMontreal.CA> Organization: Apple Computer Inc., Cupertino, CA Lines: 44 In article <1990Aug15.154812.9145@IRO.UMontreal.CA> Martin Dubuc writes: >I recently modified the MultiXfer telecom app. All worked well until >I tested it on a Mac Plus/SE. It seems to me that there is a memory problem. >My program works on a II, IIcx and IIci, but as soon as I execute it on a Plus >or SE it bombs in my initialization routine, more precisely after the >initialization of the managers, as soon as I access memory (while >accessing an array or a pointer). > >I tried to correct the problem by allocating more memory with: > > SetApplLimit((Ptr) ApplicZone() + 256000L); > MaxApplZone(); > >but the application now bombs when it calls MaxApplZone. > >Can someone point out what are the usual cases of incompatibility between a >II and a Plus/SE or explain what happens in this particular situation? Well, the II, IIcx and IIci usually have more memory to play around with, while the Plus and SE usually have a meg. Most likely when you grow the heap by 256K, you're crashing into the stack and beyond. A somewhat safer way to grow the heap would be to do something like this: bytesToGrow = StackSpace() - 1000L; SetApplLimit((Ptr) ApplicZone() + bytesToGrow); MaxApplZone(); StackSpace() returns the number of bytes between the current stack pointer and the end of the application heap. Leaving some extra bytes for the stack to expand is a good idea, and you'll have to play around to determine what a good amount is... steve -- ____________________________________________________________________ Steve Christensen Internet: stevec@goofy.apple.com Apple Computer, Inc. AppleLink: STEVEC 20525 Mariani Ave, MS 81-CS CompuServe: 76174,1712 Cupertino, CA 95014 "You just contradicted me." "No I didn't." ____________________________________________________________________