home *** CD-ROM | disk | FTP | other *** search
- Path: lll-winken.llnl.gov!parc!boehm
- From: boehm@parc.xerox.com (Hans Boehm)
- Newsgroups: comp.lang.c++
- Subject: Re: Why don't you use garbage collection
- Date: 16 Apr 1996 23:06:45 GMT
- Organization: Xerox Palo Alto Research Center
- Message-ID: <4l1965$oaa@news.parc.xerox.com>
- References: <4kiai0$mjd@dfw-ixnews8.ix.netcom.com> <66iHfO6PoYB@37.viking.ruhr.com>
- NNTP-Posting-Host: siria.parc.xerox.com
- X-Newsreader: NN version 6.5.0 #8 (NOV)
-
- gasper@viking.ruhr.com (Ortwin Gasper) writes:
- >- If you want that a program never fails if the amount of needed memory m
- > is <= C*n with n = the available memory and C a constant 0 < C <= 1, you
- > must use copying collectors. But in this case, you can't program in
- > 'normal' C++. You must remember the position of all pointers to the
- > collected area, you must handle problems like 'what happens if the
- > collector moves a class object while there is a stack frame from a
- > member function of this object still valid'.
- > ==> You can write C++-Programs using such a collector, but these
- > programs won't look like C++, are hard to debug (and slow).
-
- If you substitute "compacting" for "copying", then I basically agree.
- (There are also sliding compacting collectors that compact in place.
- I believe they're sometimes the right solution.)
-
- But it's important to remember:
-
- 1. This problem isn't limited to garbage collection. Malloc and new
- have the same problem.
- 2. Evidence I've seen so far suggests that the problem is typically not serious
- with a good allocator. Fragmentation cost is almost always much less than the
- factor of 2 lost by a traditional copying collector. It still matters if
- worst-case space usage is a real issue, but probably not if you are trying to
- minimize expected case space usage. Admittedly the evidence I've seen
- hasn't included applications that run for years.
- 3. There exist bad allocators. (Our garbage collector is not ideal in this
- respect, though it usually doesn't do too badly.)
-
- Hans-J. Boehm
- (boehm@parc.xerox.com)
- Standard disclaimer ...
-