[gclist] More questions for the FAQ

Chris Reedy creedy@mitre.org
Thu, 21 Mar 1996 08:46:59 -0500


At 12:16 PM 3/21/96 +0100, Marc Shapiro wrote:
> || Date: Wed, 20 Mar 96 13:05:19 EST
> || From: David Chase <chase@centerline.com>
> || 
> || Q: What languages include/require/provide-by-default garbage collection?
>
>The Macintosh operating system (MacOS) does garbage collection internally.
>>From what I am told, applications register their roots in an object table.
>The system does reference counting.
>
I wouldn't call what the MacOS does garbage collection.  It uses handle
based management of main memory.  Memory is allocated and the pointer to
that memory is placed in a global array.  A pointer to the entry in the
global array is returned to the caller.  The operating system can compact
memory by moving memory blocks and adjusting the pointers in the array.  As
far as I know (I have done some Macintosh programming) no tracing of
pointers is done to determine what is or is not garbage.  If you allocate a
handle and lose track of it you have a memory leak (at least until your
application terminates).

Also, the use of handle based storage  was an artifact of the initial
memory starved configurations of the Mac.  Most newer programs use pointer
based storage (which was always an option anyway) rather than handle based
storage.  This appears to have occurred for a lot of reasons, including
making the compiler's job easier, making the programmer's job easier (you
had to lock handles if you didn't want the OS to move them which was
important if you, for example, passed the address of an element of a
structure as an argument to a procedure), better performance (not having to
doubly dereference pointers all the time), and, in general, because the
advantages in terms of fragmentation due to compacting memory weren't
important once the machines were no longer memory starved.

  Chris

This is an informal message and not an official Mitretek Systems position.
Dr. Christopher L. Reedy, Mail Stop Z667
Mitretek Systems, 7525 Colshire Drive, McLean, VA 22102-3481
Email: creedy@mitretek.org  Phone: (703) 883-7183  FAX: (703) 883-6991