home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!snorkelwacker.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.92Aug28192437@arolla.idiap.ch>
- Date: 28 Aug 92 23:24:37 GMT
- References: <DAVEG.92Aug20043156@synaptx.synaptics.com> <28623@vedge.UUCP>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 35
- In-reply-to: hendrik@vedge.UUCP's message of 27 Aug 92 18:33:04 GMT
-
- In article <28623@vedge.UUCP> hendrik@vedge.UUCP (Hendrik Boom) writes:
-
- daveg@synaptics.com (Dave Gillespie) writes:
- : I did; as far as I can tell, the GC has to call destructors, and it's
-
- One of my nightmares in a Lisp garbage collector is the destructor
- from Hell that retrieves otherwise moribund objects and makes them
- accessible again. Do we have to do another garbage collection to see if
- objects are really free? And if they are, do we have to call
- the destructor from hell again? and again? and again?and again?
-
- Please do not confuse GC finalization with C++ destructors. The two
- concepts are very different. Finalization routines should be written
- specifically for the purpose of finalization; it would be wrong for
- the GC to call the destructor for finalization.
-
- Most finalization routines are really error handlers. They detect that
- some object that should have been destroyed explicitly (e.g., a file
- descriptor, a window) somehow got lost; they can fix the problem (to
- allow your buggy program to continue running) and send out a bug
- report. But you should (almost) never rely on finalization to destroy
- such objects for you as a matter of course.
-
- So, finalization is really something that most users won't have to
- deal with, and the usual finalization routine will be very simple and
- straightforward. Because they are used rarely and not for very
- complicated things, the finalization hooks do not need to be very
- "user friendly" and might impose some restrictions on what you can do
- (just like you can't call "new" from the "new_handler").
-
- Yes, finalization (in particular, in a conservative GC) is
- non-trivial; Boehm posted a reference to a paper about finalization in
- a conservative GC maybe this week. You may want to look it up.
-
- Thomas.
-