Memory on the Mac, was Re: A few observations Re: Clean

Alan Grover awgrover@mail.msen.com
8 Apr 98 18:23:01 -0500


In the thread "Re: A few observations Re: Clean", on Wed, Apr 8, 1998 4:37
PM, Adrian Hey <mailto:ahey@iee.org> wrote:
>I'm not really sure I understand what the problem is...
>Is it a Clean implementation problem? If so it shouldn't be to hard to
fix.
>or...
>Is it an OS problem? If so it must afflict applications programmers using
>whatever language. I wonder what they do about it. The only OS I really
>know much about is RiscOS and I know its easy for RiscOS apps to get more
>memory from the OS if they need it (provided the OS has some free of
course).

Memory management is less than ideal on the MacOS. An application is
assigned a chunk of memory as it's heap (that's "application heap", not
malloc heap or Clean heap). All the functions in the OS that allocate
memory will take it from the application heap by default (the code lives in
there too). It's as if each application had a fixed sized memory partition.

This is known to be a bad thing on the Mac. The user has to keep adjusting
the size if conditions change (like building a huge program, or opening
lots of documents) by quiting, changing, and re-running.

There are a few ways around this problem, though none without liabilities.
You (the programmer) can request memory allocation from the "rest of
memory" rather than from your application heap. However, since the memory
manager on the Mac is not so good, this can fragment memory. I can see you
scratching your head. This is a problem because all applications share the
memory as if it were one big heap, there is no per-process VM. Furthermore,
an application's heap must be contiguous. The later MacOS versions
(starting with 7.5  I think) do have VM  so the fragmentation is mitigated
to some extent, but still treating all of memory as one big heap. 

I've simplified some, but basically, memory management on the Mac sucks.

>It seems to me that this is a pretty serious problem. You might be
>able to live with it whilst developing 'experimental' software on your
>own machine. But what if you were to use Clean for a commercial
>application? You wouldn't know how much memory end users had, so you would
>be wise to set the figures small. But somebody who had invested in 256Mb
RAM
>might get a bit annoyed if the application only used 8Mb and then stopped
>complaining about lack of memory.

This is exactly what happens on the Mac, though usually the applications
crash when they exhaust their memory partition. The user has to quit, then
reset the size of the application to something larger when it is needed.
And it does annoy us.

>Have I missed something here?
>Am I being stupid?

Well, you didn't know how primitive the MacOS memory management is. So, I
would say that it is not you that is stupid. (Hey, for 1980 the system was
actually pretty great. It was WAY better than DOS, but it hasn't improved
that much since then).