comp.lang.ada
 help / color / mirror / Atom feed
From: billwolf@hubcap.clemson.edu (William Thomas Wolfe,2847,)
Subject: Re: Garbage Collection
Date: 5 Jan 89 08:13:49 GMT	[thread overview]
Message-ID: <4016@hubcap.UUCP> (raw)
In-Reply-To: 4206@enea.se

From article <4206@enea.se>, by sommar@enea.se (Erland Sommarskog):
> I'm trying to get Bill Wolfe to explain how he his deallocation-on-
> block-exit scheme would work in an example I had. [...] 
> I repeat the exmample with some clarifcations.
> 
> We have:
>    Generic 
>       Data_type is limited private;
>       Procedure -- Assign, "<" and ">" 
>    Package Tree_handler
>       Tree_type is private;
>       
> Assume further that we instantiate this package with Some_access_type, 
> it could be an imported limited type, it could be a locally defined.
> Then we have the procedure:
> 
>     Procedure Insert_data_to_tree(Tree : in out Tree_type;
>                                   Data_of_some_sort : in Any_type); 
                                                           ^^^^^^^^

                                        You mean Data_type, right?

>     Reference : Some_access_type;

                     How about "access Data_Type"?  It is illegal to
                     reference Some_access_type directly, since it
                     is not a generic formal parameter.  We can only 
                     reference Data_Type, which in this particular 
                     instantiation will refer to Some_access_type.

>     Begin
>        Reference := new Some_type;  -- Or subprogram call for external type

           Let's say "Reference := new Data_Type;", to make things legal.

>        Prepare(Reference, Data_of_some_sort);

           Prepare is not a generic parameter; I frankly don't see
           why you need a call to such a procedure anyway.  I'll replace
           it with "Assign (Reference.all, Data_of_some_sort);". 
 
>        Insert(Tree, Reference);

           What exactly is Insert doing?  It would make more sense to write:

            begin
              -- find the node for which the new value is to
              --   become either the leftmost or rightmost child,
              --   create a new child, and assign the new data value
              --   to the appropriate field of the new node.  At some
              --   point in this process, there may be some pointer 
              --   manipulations; it really doesn't matter where.  But
              --   let's assume the tree is initially empty.  Then, 
              TREE := new BINARY_TREE_NODE;
              ASSIGN (NEW_NODE.DATA_VALUE, DATA_OF_SOME_SORT);
              -- since pointer types are automatically initialized to
              --   null, we don't have to worry about initializing
              --   the left child and right child fields, so we're done.
           end INSERT;
 
>     End Insert_data_to_tree;
>     
> The Assign procedure which we provide when we instantiate the tree handler 
> is simply:
>    Procedure Assign(A : in out Some_access_type; B : in Some_access_type) is
>    Begin
>       A := B;
>    End Assign;
>    
> Now, what happens with Reference.all on exit of Insert_to_data_tree, with    
> your scheme? (Assume there is no user-written DESTROY procedure.) Would
> Reference.all be deallocated although there still is a living reference  
> to it in Tree? 

      First of all, I always require the user to pass in a DESTROY procedure.
      So my initial reaction is that this is a malformed ADT.  But let's
      assume the existence of such a malformed ADT.  We'll assume further
      that we have a pointer variable such as Reference.  Destruction of
      a pointer consists simply of destroying the pointer, and does not
      imply destruction of what it points to.  Destruction of an ADT
      which happens to be implemented via an initial pointer (as in Tree)
      does imply destroying the transitive closure of what it points to.

>>> 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.
>>
>>     Advanced debugging tools should be used to address this issue.
> 
> So why can't these "advanced debugging tools" be used to "pin down
> the exact state of the system" when we have garbage collection?

     They can, but only the exact state of one particular execution,
     and not the precise state of the theoretical system in general.

     A debugging tool exists simply to help you find errors which show
     up in one particular situation.  It does not help you understand
     the piece of software as a theoretical structure, which is essential
     if one is to perform nontrivial modifications to a system.  It is
     this theoretical imprecision which causes problems.

> 
>>   I'm quite aware of Eiffel, and I have just shown (in another article)
>>   how reliance upon garbage collection is a sure way to get your ADT
>>   rejected by users who are programming critical applications.  This
> 
> There is good chance that your ADT will be rejected anyway. The critical 
> developper looks at you and says: "You use Unchecked_dellocation? Sorry, 
> then I can't use your ADT. Memory fragmention will cause too great a 
> time penalty when the system have lived for a while." 

     Allocation/deallocation routines exists which automatically
     collapse adjacent blocks of free storage into larger blocks,
     which minimizes the problem.  In general, this is the *compaction*
     question, which is orthogonal to the GC question.  It is properly
     directed at the allocation/deallocation system and not at the
     ADT designer.  It is conceivable that an allocation/deallocation
     system could be designed in such a way as to spread the costs of
     compaction evenly over each allocation/deallocation request, thus
     meeting all requirements at the same time. 


                                            Bill Wolfe

                                    wtwolfe@hubcap.clemson.edu

  reply	other threads:[~1989-01-05  8:13 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1988-12-31  0:04 Garbage Collection Erland Sommarskog
1989-01-05  8:13 ` William Thomas Wolfe,2847, [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-08-18  0:00 garbage collection Ronald Ayoub
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 ` Pascal MALAISE
1999-08-20  0:00   ` David Botton
1999-08-18  0:00 ` Gisle S�lensminde
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-28 19:20 Erland Sommarskog
1988-12-30  0:52 ` Bill Wolfe
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