• Hello MLAers! We've re-enabled auto-approval for accounts. If you are still waiting on account approval, please check this thread for more information.

Grow reserved memory on Mac OS 7

Hi All,

I'm new to mac programming, and using MPW to develop a simple application. Could someone with a better grasp of Mac System 7 (v7.5.5) development let me know where i'm going wrong?

Allocating a large rectangle with NewGWorld fails due to an OOM error (-108). I was able to solve this by using "get info" and increasing the reserve memory above the 512k the application is automatically allocated. I wish to be able to do that programmatically, however I am unable to actually grow the heap size using:

SetApplLimit((Ptr) GetApplLimit - 10000L);
OSErr memErr = MemError();


After running the above snippet memErr consistently contains -108, the same out of memory error (This happens no matter what size I attempt to grow the heap by). 

To answer the obvious question, yes I have lots of free memory available on the system, the largest unused block is over 20MB.

As far as I can tell from looking at https://www.vintageapple.org/inside_r/pdf/Memory_1992.pdf, this function should reserve more memory for my application.

Thanks!

 
System 7 can’t dynamically change partition size beyond what the Finder allocated you on launch. If you need a bigger partition, you must request it at launch time by increasing the preferred partition size in your SIZE -1 resource in the application resource file (which sets the defaults as seen in Get Info). 

 
By the way, your example is actually shrinking the size of your heap. You are getting the current limit, then shrinking it by 10k. You may have based that on an example in Inside Macintosh: Memory (p. 1-38) that is intended to show how to make more space available for the stack (by shrinking the heap!). To maximize heap size to the Finder’s limit based on your SIZE resource, simply call MaxApplZone(). 

 
Last edited by a moderator:
Back
Top