Mac OS Memory Management - Object Orientation

Object Orientation

The rise of object-oriented languages for programming the Mac – first Object Pascal, then later C++ – also caused problems for the memory model adopted. At first, it would seem natural that objects would be implemented via handles, to gain the advantage of being relocatable. However, these languages, as they were originally designed, used pointers for objects, which would lead to fragmentation issues. A solution, implemented by the THINK (later Symantec) compilers, was to use Handles internally for objects, but use a pointer syntax to access them. This seemed a good idea at first, but soon deep problems emerged, since programmers could not tell whether they were dealing with a relocatable or fixed block, and so had no way to know whether to take on the task of locking objects or not. Needless to say this led to huge numbers of bugs and problems with these early object implementations. Later compilers did not attempt to do this, but used real pointers, often implementing their own memory allocation schemes to work around the Mac OS memory model.

While the Mac OS memory model, with all its inherent problems, remained this way right through to Mac OS 9, due to severe application compatibility constraints, the increasing availability of cheap RAM meant that by and large most users could upgrade their way out of a corner. The memory wasn't used efficiently, but it was abundant enough that the issue never became critical. This is perhaps ironic given that the purpose of the original design was to maximise the use of very limited amounts of memory. OS X finally did away with the whole scheme, implementing a modern sparse virtual memory scheme. A subset of the older memory model APIs still exist for compatibility as part of Carbon, but map to the modern memory manager (a threadsafe malloc implementation) underneath. Apple recommends that OS X code use malloc and free "almost exclusively".

Read more about this topic:  Mac OS Memory Management

Famous quotes containing the words object and/or orientation:

    If thinking is like perceiving, it must be either a process in which the soul is acted upon by what is capable of being thought, or a process different from but analogous to that. The thinking part of the soul must therefore be, while impassable, capable of receiving the form of an object; that is, must be potentially identical in character with its object without being the object. Mind must be related to what is thinkable, as sense is to what is sensible.
    Aristotle (384–322 B.C.)

    Every orientation presupposes a disorientation.
    Hans Magnus Enzensberger (b. 1929)