Path: utzoo!attcan!uunet!mcsun!ukc!dcl-cs!aber-cs!athene!pcg From: pcg@cs.aber.ac.uk (Piercarlo Grandi) Newsgroups: comp.object Subject: Re: C++ and garbage collection (Was: Re: What is Objective C?) Message-ID: Date: 19 Sep 90 10:54:30 GMT References: <1990Sep12.074154.657@tukki.jyu.fi> <1990Sep16.090226.11051@tukki.jyu.fi> <57523@microsoft.UUCP> Sender: pcg@aber-cs.UUCP Organization: Coleg Prifysgol Cymru Lines: 68 Nntp-Posting-Host: teacha In-reply-to: jimad@microsoft.UUCP's message of 18 Sep 90 17:50:14 GMT On 18 Sep 90 17:50:14 GMT, jimad@microsoft.UUCP (Jim ADCOCK) said: jimad> In article jimad> pcg@cs.aber.ac.uk (Piercarlo Grandi) writes: pcg> Also, there is no degree of conservativeness in a storage reclaimer -- pcg> either it is conservative, and it will consider as a pointer any word pcg> whose numeric value can be interpreted as an address into the heap, or pcg> it is not conservative, and it *knows* which words are pointers. jimad> While this statement is probably only intended as a definition: jimad> "A reclaimer is conservative if it always assumes any numerical jimad> value could be a pointer to [into] an object to be retained" -- jimad> in practice things are not so black and white. Rather the definition goes the other way round: a non conservative storage reclaimer (whether manual or automatic, ref.counting or g.c.) is one that knows which values are pointers -- one that has to guess is by definition conservative, because it has to err on the safe side, assuming that certain values are pointers when in fact they are not. There are degrees of efficiency, and maybe this is what Jim Adcock is referring to; efficiency is inversely related to the percentage of values mistaken for pointers when they are not. Note that there is no degree in safety instead -- un unsafe storage reclaimer is one that will reclaim _any_ 'in-use' storage. In the case of a conservative storage reclaimer it will be unsafe if even a single pointer value is not recognized as such (as long as the storage manager and the programmer agree on what is a pointer). jimad> [ ... a number of special cases, e.g.: ... ] jimad> You can have systems where referred-to objects must be jimad> quad-aligned to be kept alive -- objects on two-byte alignment jimad> don't count. jimad> [ ... a number of other special cases ... ] But really all these special cases relate to the definition of what is 'in-use' or, equivalently, what is a pointer, and this has nothing to do with whether storage reclamation is manual or automatic, or if g.c. or ref.counting is used, or whether the g.c. is conservative or not. jimad> Seems to me for any GC system to work, there are a set of rules jimad> on fair usage of objects and references that must be obeyed. jimad> "Conservative" systems [in whatever shade on black, white or jimad> grey] are no different in that regard. Absolutely not! There is no need of ad-hoc rules for GC systems. There must be a definition of 'in use' that both the programmer and the storage reclaimer agree upon, but this is an essential requisite of *any* (automatic,manual,ref.counting or g.c. based) storage reclamation scheme that does not use telepathy (for reading the programmer's mind) or foresight (to know which storage area will never actually be used again). If your program locates employee records using the employee's name represented as a string, and then an employee retires, and you try to dispose of the relevant record by saying free("A.Retiree"); in a C program, you have written a wrong program, period. -- Piercarlo "Peter" Grandi | ARPA: pcg%uk.ac.aber.cs@nsfnet-relay.ac.uk Dept of CS, UCW Aberystwyth | UUCP: ...!mcsun!ukc!aber-cs!pcg Penglais, Aberystwyth SY23 3BZ, UK | INET: pcg@cs.aber.ac.uk