68kMLA Classic Interface

This is a version of the 68kMLA forums for viewing on your favorite old mac. Visitors on modern platforms may prefer the main site.

Click here to select a new forum.
Grow reserved memory on Mac OS 7
Posted by: performa580cd on 2020-07-16 17:12:22
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!

Posted by: Crutch on 2020-07-16 19:50:03
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). 

Posted by: Crutch on 2020-07-16 19:54:07
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(). 

Posted by: performa580cd on 2020-07-17 06:54:44
Thanks very much, I didn't realise that an application's reserved memory could not be change.

Thanks @Crutch!

1