home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!usc!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.92Aug20143223@arolla.idiap.ch>
- Date: 20 Aug 92 18:32:23 GMT
- References: <1992Aug6.014619.2111@ucc.su.OZ.AU> <DAVEG.92Aug17231725@synaptx.synaptics.com>
- <1992Aug19.180252.12942@mole-end.matawan.nj.us>
- <DAVEG.92Aug20043156@synaptx.synaptics.com>
- Sender: news@ai.mit.edu
- Reply-To: tmb@idiap.ch
- Organization: IDIAP (Institut Dalle Molle d'Intelligence Artificielle
- Perceptive)
- Lines: 33
- In-reply-to: daveg@synaptics.com's message of 20 Aug 92 11:31:56 GMT
-
- In article <DAVEG.92Aug20043156@synaptx.synaptics.com> daveg@synaptics.com (Dave Gillespie) writes:
-
- In article <1992Aug19.180252.12942@mole-end.matawan.nj.us> mat@mole-end.matawan.nj.us writes:
-
- > You've answered your own question in the negative. If the destructor
- > has an effect on the program's output, and it is accidentally called
- > by the GC instead of by its proper deletion, the program's output will
- > depend on the exact properties of the GC system and the exact sequencing
- > of internal states of the program and of the program's runtime internals'
- > states. It might work correctly by accident in testing, and fail
- > disastrously in service.
-
- Sorry, I didn't make myself clear. I realize that allowing GC to call
- a destructor would add one more case where destructors with side effects
- could surprise the C++ programmer. My question was, is that potential
- for surprise enough to kill the idea of garbage collection in C++?
-
- My answer is no, it just means C++ programmers who use garbage collection
- have to be a little careful about what they put in their destructors.
-
- I think the answer is simpler than that. Delete should continue to
- work as it does (including returning memory to the system).
-
- In addition to that, there may be facilities to allow the programmer
- to specify finalization of heap objects that are about to be collected
- but have not been "deleted". Such a facility would not require any
- language changes; something like "gc_set_finalization_hook(void*,void
- (*f)(void*))" might do the trick. Some people may prefer to use such a
- facility simply to detect memory leaks in existing programs, while
- others might want to use it, for example, to release external
- resources.
-
- Thomas.
-