comp.lang.ada
 help / color / mirror / Atom feed
From: kaz@.crest.nt.com (Kaz Kylheku)
Subject: Re: newbie Q: storage management
Date: 1997/04/30
Date: 1997-04-30T00:00:00+00:00	[thread overview]
Message-ID: <5k85tm$1jh@bcrkh13.bnr.ca> (raw)
In-Reply-To: 336754A0.41C6@magellan.bgm.link.com


In article <336754A0.41C6@magellan.bgm.link.com>,
Samuel A. Mize <smize@magellan.bgm.link.com> wrote:

>It's the programmer's responsibility to destroy individual objects with
>Unchecked_Deallocation.

Okay, that's basically what I wanted to know. Thank you (and others) very much.

>Note that dynamic storage is often useful WITHOUT reclamation.  For instance,
>if you read some kind of dictionary into your program from a file, you might
>put it into a linked list so you aren't tied to a specific table size, even
>though you will never delete any of the terms.

Yes, this is true. Another common example is compilers which never deallocate
their symbol table data structures, syntax trees and the like. It's not
uncommon to not even implement deletion operations from such structures.
The idea is that the compiler is short lived, and works on reasonably
small sets of data.

>>Is it the reponsibility of the language implementation to
>> automagically detect when an object is no longer reachable and do the
>> appropriate deallocation, even if garbage is not collected?
>
>Nope.  You can chew up the entire system's memory with this program:
>
>  procedure Just_Kill_Me is
>    type integer_access is access integer;
>    x: integer_access;
>  begin
>    loop
>       x := new integer;
>    end loop;
>  end Just_Kill_Me;
>
>Is this the best language-design tradeoff?  well, yes and no, respectively.
>It depends on what you want to use the language for, and how you want to
>use it.

Isn't it funny how deletion is usually more complicated than creation? I mean
in general. Pick a data structure at random, and chances are that its deletion
algorithm is more difficult than insertion. In file systems, deletion of files
seems to pose more problems than file creation.  (Consider, e.g., that SunOS
updates inodes synchronously when deleting files, to forestall the possibility
of irrecoverable corruption, but when creating files it does not act this way).
Inserting into a binary search tree, balanced or not, is a heck of a lot easier
than deleting.  And even in simple linked lists, removal of nodes can be harder
than insertion.

In some way it makes perfect sense that Ada doesn't provide a handy ``delete''
to accompany the ``new'', since a lot more care is required when an object
is being deleted than when it's being created.




  parent reply	other threads:[~1997-04-30  0:00 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-29  0:00 newbie Q: storage management Kaz Kylheku
1997-04-30  0:00 ` Samuel A. Mize
1997-04-30  0:00   ` Jon S Anthony
1997-05-02  0:00     ` Samuel A. Mize
1997-05-02  0:00       ` Jon S Anthony
1997-05-03  0:00       ` Robert Dewar
1997-05-05  0:00         ` Samuel A. Mize
1997-05-06  0:00           ` Robert Dewar
1997-05-06  0:00             ` Robert A Duff
1997-05-08  0:00               ` Jon S Anthony
1997-05-08  0:00                 ` John G. Volan
1997-05-09  0:00                   ` Jon S Anthony
1997-05-09  0:00                     ` John G. Volan
1997-05-13  0:00                       ` Jon S Anthony
1997-05-13  0:00                         ` Robert Dewar
1997-05-09  0:00                 ` Robert A Duff
1997-05-09  0:00                   ` Jon S Anthony
1997-05-10  0:00                     ` Robert A Duff
1997-05-12  0:00                       ` Jon S Anthony
1997-05-09  0:00                   ` Brian Rogoff
1997-05-10  0:00                     ` Robert A Duff
1997-05-10  0:00                   ` Robert Dewar
1997-05-09  0:00                 ` Robert Dewar
1997-05-13  0:00                   ` Jon S Anthony
1997-05-06  0:00           ` Michael F Brenner
1997-05-06  0:00             ` Assuaging sour grapes :-) [was: newbie Q: storage management] John G. Volan
1997-05-07  0:00               ` Stephen Posey
1997-05-07  0:00               ` Kevin Cline
1997-05-07  0:00                 ` John G. Volan
1997-05-07  0:00                   ` John G. Volan
1997-05-07  0:00                     ` Robert Dewar
1997-05-08  0:00                   ` Jon S Anthony
1997-05-08  0:00                 ` Jon S Anthony
1997-05-08  0:00               ` Dynamic binding of packages Nick Roberts
1997-05-08  0:00                 ` John G. Volan
1997-05-07  0:00             ` newbie Q: storage management Jeff Carter
1997-05-07  0:00             ` Robert Dewar
1997-05-09  0:00               ` Robert I. Eachus
1997-05-10  0:00                 ` Robert Dewar
1997-05-03  0:00       ` Robert Dewar
1997-05-03  0:00         ` Jon S Anthony
1997-05-04  0:00           ` Robert Dewar
1997-05-05  0:00         ` Samuel A. Mize
1997-05-04  0:00       ` Kevin Cline
1997-05-04  0:00         ` Robert Dewar
1997-04-30  0:00   ` kaz [this message]
1997-05-02  0:00   ` Samuel A. Mize
1997-05-04  0:00     ` Robert Dewar
1997-04-30  0:00 ` Jon S Anthony
1997-05-02  0:00   ` Robert Dewar
1997-05-04  0:00     ` Kaz Kylheku
1997-05-04  0:00       ` Robert Dewar
1997-04-30  0:00 ` Marinus van der Lugt
1997-04-30  0:00   ` Jon S Anthony
1997-05-02  0:00     ` Robert Dewar
1997-04-30  0:00 ` Robert I. Eachus
1997-05-02  0:00 ` Nick Roberts
1997-05-03  0:00   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1997-05-08  0:00 Jon S Anthony
1997-05-09  0:00 ` Robert Dewar
1997-05-09  0:00   ` Robert A Duff
1997-05-10  0:00     ` Fergus Henderson
1997-05-10  0:00       ` Robert A Duff
1997-05-12  0:00       ` Jon S Anthony
1997-05-13  0:00         ` Robert Dewar
1997-05-10  0:00 ` Fergus Henderson
1997-05-10  0:00   ` Robert Dewar
1997-05-13  0:00   ` Jon S Anthony
replies disabled

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