From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.7 required=5.0 tests=BAYES_00,INVALID_DATE, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 Xref: utzoo comp.lang.misc:1386 comp.lang.modula2:741 comp.lang.ada:1096 Path: utzoo!utgpu!water!watmath!clyde!att-cb!att-ih!pacbell!ames!husc6!cca!g-rh From: g-rh@cca.CCA.COM (Richard Harter) Newsgroups: comp.lang.misc,comp.lang.modula2,comp.lang.ada Subject: Re: Garbage Collection Message-ID: <26413@cca.CCA.COM> Date: 1 Apr 88 05:43:09 GMT References: <145@krafla.rhi.hi.is> <272@fang.ATT.COM> <429@zap.UUCP> <8196@sol.ARPA> <628@ra.rice.edu> <26358@cca.CCA.COM> <632@ra.rice.edu> Reply-To: g-rh@CCA.CCA.COM.UUCP (Richard Harter) Organization: Computer Corp. of America, Cambridge, MA List-Id: In article <632@ra.rice.edu> boehm@titan.rice.edu (Hans Boehm) writes: >> There is problably something I am missing, but I don't quite see >>how you can implement garbage collection in C without collateral assumptions >>-- how is the garbage collector supposed to know that that a block is free? > This is usually, but not always, possible. The idea is to use a traditional >non-compacting mark-sweep collector. On a UN*X system, we start by scanning >the registers, stack, data, and (statically allocated) bss segments for >any addresses of valid allocated objects. We subsequently scan allocated >objects we find in the same way. For a typical C program, all reachable >objects can be found in this manner. (Storing exclusive or'ed pointer >values, tagged pointers, and similiar programming tricks, as well as some >rarely used (for C) compiler optimization techniques may break this scheme.) I see. My block was in not thinking of the entire address space of the program as accessible. For our purposes it is not (we live in portability land and are not allowed to do things like that :-)). That is one reason we did our own allocator (in C) -- it allows us to track down memory problems portably. I still don't see how a garbage collector helps with premature deallocation, unless you scrap deallocation entirely, and rely entirely on garbage collection. The problem with garbage collectors in the old days was that they did garbage collection when the available space was allocated. This works well enough until the actual amount of space allocated starts to approach the amount of available space, and then the garbage collector starts thrashing. Is this a problem? If not, how do you deal with it? -- In the fields of Hell where the grass grows high Are the graves of dreams allowed to die. Richard Harter, SMDS Inc.