comp.lang.ada
 help / color / mirror / Atom feed
From: sommar@enea.se (Erland Sommarskog)
Subject: Re: Garbage Collection
Date: 28 Dec 88 19:20:05 GMT	[thread overview]
Message-ID: <4200@enea.se> (raw)

I gave an example where I stored pointers in a tree, and tried
to make Bill Wolfe explain how this should work with his idea 
with deallocation on block exit. He answered, but I wouldn't 
say I'm satisfied... I still don't see where he is heading.

>   Since the user supplied an access type as the type of object to be
>   stored in the tree, the user bears full responsibility for making
>   responsible use of the fact that he/she is dealing with a tree of pointers.

Well, assume that Assign the procedure I write for Some_access_type 
(the type I store in the tree) is simply A := B. With your scheme I 
can't but see that the object I allocated is deallocated when I exit  
my procedure, although I still have a reference to it, stored in
the tree.
  Bill, tell me, what is wrong here? My understanding of your proposal,
or the program I have written? If you think the latter, explain to me
how the compiler should detect the error I'm doing. Or do you really 
think such an error should remain undiscovered until run-time? And
does that rhyme with your eagerness for simplify maintenance?

>> Several times in this discussion Bill Wolfe has claimed that 
>> garbage collection is a trouble-maker for maintainers. In what way? 
>
>      When there is great difficulty deciding whether a given object 
>      exists or not, the maintainer experiences great difficulty 
>      pinning down the precise state of the program.  

You have just given an excellent argument for garbage collection.
With garbage collection, only the objects that have references
exist. Without, there may be other objects that are unreachable.
With garbage collection you are sure of that all initiated non-null
references point to actual objects. Without, you may by mistake
be pointing straight into free space, or right in the middle of
some completely other kind of object. 
  The only incertainty you have with garbage collection is whether 
a non-referred object has yet been returned to free memory, depending
on wether the garbage collector has come there or not. But since 
the object no longer is part of the system, this question is of 
little interest.

>>   Much worse for maintainence is when the system dies with "System 
>> access violation" or "segmentation fault" from time to time and you 
>> don't know why. The reason may be that an allocated area was erroneously 
>> released and then reused and the original data, that someone appearently 
>> is relying in, has been over-written. Or because an already deallocated 
>> was deallocated a second time.

I forgot: When the system chokes with "heap full" and you as a maintainer
is trying to find where all space is being wasted. With garbage collection
you at least know that all this memory is being used. Without, you don't 
know if it is just memory leakage or real overuse.

>    DESTROY procedures are easy to write, need only be written once
>    per ADT, and can be reused indefinitely.  GC costs us the
>    computer time required to repeatedly determine which storage
>    is in use and which is not, and this cost must be paid repeatedly
>    AT RUN TIME.  Given that this PERMANENT, RUN_TIME COST can be
>    avoided by simply communicating the fact that a particular object
>    is no longer needed, GC is a rather costly crutch for lazy programmers. 

1) You have several times stated that the callers of your ADTs 
are responsible for that their destroy procedures are called.
So it's not only to write them. You must remember to call them
too. And when you forget, it takes time find out where.

2) Much of this talk reminds of what hear from C programmers when
range and type checking is being discussed. And the same arguments  
apply. If all programmers were skilled enough to do everything
right we wouldn't need Ada or high-level langauges at all. Actually,
if everyone else is taking help of computers these days, why shouldn't
programmers do?
  Just like range and type checking, garbage collection is a device
that increases our thrust in that the system does what we intended.

3) I recommend you to read "Object-Oriented Software Construction"
by Bertrand Meyer. There he explains why garbage collection is
necessary in an object-oriented system. He also describes how the
garbage collector is implemented in the Eiffel system. (Eiffel is
an object-oriented language, devised by Mr. Meyer, and comemercially
available.) 
-- 
Erland Sommarskog
ENEA Data, Stockholm              This signature is not to be quoted.
sommar@enea.se

             reply	other threads:[~1988-12-28 19:20 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-12-28 19:20 Erland Sommarskog [this message]
1988-12-30  0:52 ` Garbage Collection Bill Wolfe
1988-12-30 19:55   ` Life under implicit destruction William Thomas Wolfe,2847,
  -- strict thread matches above, loose matches on Subject: below --
1999-08-18  0:00 garbage collection Ronald Ayoub
1999-08-18  0:00 ` Gisle S�lensminde
1999-08-18  0:00 ` Pascal MALAISE
1999-08-20  0:00   ` David Botton
1999-08-18  0:00 ` tmoran
1999-08-18  0:00   ` Keith Thompson
1999-08-19  0:00     ` Tucker Taft
1999-08-19  0:00       ` Robert Dewar
1999-08-19  0:00       ` Robert Dewar
1999-08-20  0:00     ` tmoran
1999-08-20  0:00       ` Keith Thompson
1999-08-20  0:00         ` Matthew Heaney
1999-08-20  0:00           ` Keith Thompson
1999-08-21  0:00             ` Matthew Heaney
1999-08-21  0:00             ` Robert Dewar
1999-08-21  0:00               ` Matthew Heaney
1999-08-21  0:00           ` Robert Dewar
1999-08-21  0:00         ` Brian Rogoff
1999-08-21  0:00       ` Robert Dewar
1999-08-18  0:00 ` Robert I. Eachus
1999-08-19  0:00   ` Gautier
1999-08-19  0:00     ` Robert I. Eachus
1999-08-20  0:00   ` Keith Thompson
1999-08-20  0:00     ` Robert Dewar
1996-10-24  0:00 Garbage Collection H Brett Bolen
1989-01-10 19:16 Erland Sommarskog
1989-01-11 16:10 ` William Thomas Wolfe,2847,
1989-01-06 22:17 Erland Sommarskog
1989-01-08 18:40 ` William Thomas Wolfe,2847,
1989-01-09  3:56   ` Barry Margolin
1989-01-09 16:22     ` William Thomas Wolfe,2847,
1989-01-09 19:00       ` Barry Margolin
1989-01-10  2:50         ` William Thomas Wolfe,2847,
1989-01-11  9:22           ` Barry Margolin
1989-01-11 16:01             ` William Thomas Wolfe,2847,
1989-01-11 18:21               ` Barry Margolin
1989-01-12  2:43                 ` William Thomas Wolfe,2847,
1989-01-15  7:14                   ` Barry Margolin
1989-01-05 23:26 Erland Sommarskog
1988-12-31  0:04 Erland Sommarskog
1989-01-05  8:13 ` William Thomas Wolfe,2847,
1988-12-26 23:37 Erland Sommarskog
1988-12-27 21:24 ` William Thomas Wolfe,2847,
1988-12-28 16:09   ` Snorri Agnarsson
1988-12-30  0:46     ` Bill Wolfe
1988-12-27 22:24 ` Bob Hathaway
1988-12-18 20:12 Erland Sommarskog
1988-12-20 19:04 ` Bill Wolfe
1988-12-13 20:07 Erland Sommarskog
1988-12-15 19:13 ` William Thomas Wolfe,2847,
1988-12-07 15:22 Collective response to := messa ron
1988-12-11 19:11 ` Garbage Collection William Thomas Wolfe,2847,
1988-12-12  5:29   ` John Gateley
1988-12-12 18:19     ` William Thomas Wolfe,2847,
1988-12-13  1:02       ` Alexander Klaiber
1988-12-13 18:37         ` William Thomas Wolfe,2847,
1988-12-13 23:36           ` Alexander Klaiber
1988-12-14  3:26             ` William Thomas Wolfe,2847,
1988-12-14 17:16             ` Stephe Leake
1988-12-15 14:43             ` Thomas P. Morris
1988-12-14 23:30           ` John Gateley
1988-12-15 19:25             ` William Thomas Wolfe,2847,
1988-12-19 16:12               ` John Gateley
1988-12-20 19:34                 ` Bill Wolfe
1988-12-13 20:22         ` William Thomas Wolfe,2847,
1988-12-14  6:40           ` Richard A. O'Keefe
1988-12-14 17:43             ` William Thomas Wolfe,2847,
1989-01-02 17:51   ` ryer
1989-01-05  8:31     ` William Thomas Wolfe,2847,
1989-01-06 16:58   ` ryer
1989-01-08 19:24     ` William Thomas Wolfe,2847,
     [not found] <145@krafla.rhi.hi.is>
     [not found] ` <272@fang.ATT.COM>
1988-03-29 13:47   ` From Modula to Oberon Denis Fortin
1988-03-30 15:32     ` Lawrence Crowl
1988-03-30 22:41       ` Hans Boehm
1988-03-31  6:27         ` Garbage Collection Richard Harter
1988-03-31 19:49           ` Hans Boehm
1988-04-01  5:43             ` Richard Harter
1988-04-01 18:43               ` Hans Boehm
1988-04-04 23:14           ` 00704a-Liber
1986-03-16 22:24 Garbage collection "Alexander L. Wolf"
     [not found] <1979@mit-eddi.UUCP>
     [not found] ` <2144@mit-eddie.UUCP>
1984-06-18 19:28   ` Abstraction In Ada Jon Mauney
1984-06-22  7:47     ` Doug Alan
1984-06-25  2:15       ` brad
1984-07-17 10:34         ` garbage collection Eric Smith
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox