home *** CD-ROM | disk | FTP | other *** search
- 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
- From: tmb@arolla.idiap.ch (Thomas M. Breuel)
- Newsgroups: comp.lang.c++
- Subject: Re: Garbage Collection for C++
- Message-ID: <TMB.92Aug17204854@arolla.idiap.ch>
- Date: 18 Aug 92 00:48:54 GMT
- References: <1992Aug6.014619.2111@ucc.su.OZ.AU>
- <DAVEG.92Aug13025629@synaptx.synaptics.com>
- <1992Aug14.021547.15215@news.mentorg.com>
- <DAVEG.92Aug14194411@synaptx.synaptics.com> <2009@appli.se>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 27
- In-reply-to: niklas@appli.se's message of 16 Aug 92 01:10:05 GMT
-
- niklas@appli.se (Niklas Hallqvist) writes:
-
- I just wanted to say that conservative GC won't really help in all
- situations. Jonathan Shapiro taught me this useful trick once.
- When you want to do a doubly linked list to the cost of a singly
- linked one (i.e. in mem. space). Instead of having two pointers
- for the link in each node, take the "previous" and "next" pointers
- and XOR them, and store the result!
-
- Now you just need to store two entry consecutive points into the
- list, and make an iterator intelligent enough to work things out.
- This is of course a very special trick, but it IS useful, and it
- shows NO GC strategy always wins unless the programmer explicitly
- can tell what objects are live/dead, but then again, we're back to
- explicit memory management.
-
- You didn't take that seriously, did you? In any case, it's an old hat
- and it's unportable (*).
-
- Incidentally, there is a widely used, simple, efficient, more general,
- and completely portable technique for getting the same kinds of
- storage savings as with the XOR trick.
-
- Thomas.
-
- (*) In C++, there is no guarantee that there exists an integral type
- large enough to hold a pointer; ARM p.67-68.
-