Garbage collection
15-Jun-95 20:58:32
Sb: #47217-Garbage collection
Fm: Clay Spence 72713,2540
To: Greg Comeau@Comeau Cmptg 72331,3421
>>Just for the sake of discussion, that same advantage can be a disadvantage.
As with everything, it depends upon what you are trying to do and is not 100%
to allow you to concentrate on other aspects of coding. That is to say, for
something it can indeed free you "from the concern." On others, this freedom
can be quite intrusive. As such, as with everything, it should be used as
deemed appropriate.<<
I see, sort of. I have experience with at least one program that I wrote, in
which deciding how to free things was a major problem (at least, for me).
Garbage collection would have made that task much easier. Since I don't have
much experience with garbage collecting allocators, I don't really know what
trouble they can cause. I can imagine that one might occasionally have to
worry about zeroing a pointer to make sure something is freed (may as well free
it explicitly).
The allocation package I mentioned also has variants on plain malloc, and
having to think about which to use might be a problem. "GC_malloc_atomic"
allocates memory in which you promise not to store any pointers to other
allocated memory, so that the collector doesn't have to look there.
There is also "GC_malloc_ignore_off_page," which is intended for large blocks
of memory. Your program is supposed to keep a pointer to someplace in the
first 256 bytes, so that the collector won't worry about pointers into the rest
of the block. Since the collector just searches all known variables (the
stack, static variables, and allocated memory pointed to from there), it can
find accidental pointers into a block of memory and keep it, incorrectly. This
version of malloc avoids a lot of that. Apparently, you need to declare a
pointer to such a block as a "volatile", to keep optimizers from mucking it up
somehow. Clearly this is something we don't have to think about with the usual
versions of malloc, et al.
>>Enough people have put it to rest and seems to be slowly and surely more and
more. This is no real suprise.<<
It's understandable, but I'd rather not believe it.
Did I mention the C++ interface?
Clay