home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12442 < prev    next >
Encoding:
Internet Message Format  |  1992-08-17  |  1.9 KB

  1. Path: sparky!uunet!haven.umd.edu!darwin.sura.net!wupost!cs.utexas.edu!qt.cs.utexas.edu!yale.edu!yale!mintaka.lcs.mit.edu!ai-lab!life.ai.mit.edu!tmb
  2. From: tmb@arolla.idiap.ch (Thomas M. Breuel)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Garbage Collection for C++
  5. Message-ID: <TMB.92Aug17204854@arolla.idiap.ch>
  6. Date: 18 Aug 92 00:48:54 GMT
  7. References: <1992Aug6.014619.2111@ucc.su.OZ.AU>
  8.     <DAVEG.92Aug13025629@synaptx.synaptics.com>
  9.     <1992Aug14.021547.15215@news.mentorg.com>
  10.     <DAVEG.92Aug14194411@synaptx.synaptics.com> <2009@appli.se>
  11. Sender: news@ai.mit.edu
  12. Reply-To: tmb@idiap.ch
  13. Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
  14.     Perceptive)
  15. Lines: 27
  16. In-reply-to: niklas@appli.se's message of 16 Aug 92 01:10:05 GMT
  17.  
  18. niklas@appli.se (Niklas Hallqvist) writes:
  19.  
  20.    I just wanted to say that conservative GC won't really help in all
  21.    situations.  Jonathan Shapiro taught me this useful trick once.
  22.    When you want to do a doubly linked list to the cost of a singly
  23.    linked one (i.e. in mem. space).  Instead of having two pointers
  24.    for the link in each node, take the "previous" and "next" pointers
  25.    and XOR them, and store the result!
  26.  
  27.    Now you just need to store two entry consecutive points into the
  28.    list, and make an iterator intelligent enough to work things out.
  29.    This is of course a very special trick, but it IS useful, and it
  30.    shows NO GC strategy always wins unless the programmer explicitly
  31.    can tell what objects are live/dead, but then again, we're back to
  32.    explicit memory management.
  33.  
  34. You didn't take that seriously, did you? In any case, it's an old hat
  35. and it's unportable (*).
  36.  
  37. Incidentally, there is a widely used, simple, efficient, more general,
  38. and completely portable technique for getting the same kinds of
  39. storage savings as with the XOR trick.
  40.  
  41.                     Thomas.
  42.  
  43. (*) In C++, there is no guarantee that there exists an integral type
  44. large enough to hold a pointer; ARM p.67-68.
  45.