comp.lang.ada
 help / color / mirror / Atom feed
From: mjmeie@ss5.magec.com (Mike Meier)
Subject: Re: Does memory leak?
Date: Fri, 24 Mar 1995 12:29:30 GMT
Date: 1995-03-24T12:29:30+00:00	[thread overview]
Message-ID: <D5y2p7.1zL@ss3.magec.com> (raw)
In-Reply-To: 3kopao$ekg@nef.ens.fr

Duncan Sands (sands@clipper.ens.fr) wrote:
: Does Ada leak memory?  I would like to believe it doesn't, but
: how does it manage not to (without having to use unchecked
: deallocation)?

: For example, if I have a pointer to a block of memory, and I set
: that pointer to null, in simple cases I am ready to believe that
: the compiler knows I'm finished with the block... but if the
: pointer is to a complicated self-referential structure, some sort
: of black magic seems needed to work out whether I'm really
: finished with that structure or not.  Can this truly be done
: efficiently?

No, Ada doesn't leak memory.  But, some Ada programs (especially
those using C-language X-windows code ;-)) leak memory like a sieve.

In current reality, no Ada run-time environments that I'm aware of provide
automated garbage collection (unless you count deallocation of objects that
fall out of scope), including mainly Alsys and Rational/Verdix.  There have
been -long- threads on this subject in this newsgroup in the not too distant
past, and the general consensus seemed to be that garbage collection will
probably not exist in the Ada world soon.

So what do you do?  You make sure that you deallocate all dynamically
allocated objects as soon as you're done with them.  If the object is
a nested structure containing other dynamically allocated objects, you
deallocate the nested structures first.

The simplest way we found to do this was to modify the Booch components
that we use for almost all dynamic data structures to take care of this
automagically.  Of course, in Ada 83 this takes some special tweaking to
properly nested data structures containing private or limited private types.
If you want to be able to determine what data structures are leaking, you
must add a few generic parameters to identify the owner (and any limits you
want to place on the data structure for performance purposes).  We even
added a dump facility to print out to a file the memory usage of each
data structure within a process on demand.  Believe it or not, none of
this adds all that much overhead to the average data structure
manipulation.  Sure would be nice to have some of these features in
the Ada 95 Booch Components by the time we use them (1996 or 1997 maybe).
But, I digress greatly.  I hope that I gave you a useful reply somewhere
in there.



  parent reply	other threads:[~1995-03-24 12:29 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-03-22  9:06 Does memory leak? Duncan Sands
1995-03-22 12:04 ` Fred J. McCall
1995-03-23  0:37 ` Robert I. Eachus
1995-03-23 13:54   ` Arthur Evans Jr
1995-03-23 16:23     ` Robert I. Eachus
1995-03-24 21:08   ` Norman H. Cohen
1995-03-28  0:00     ` Theodore Dennison
1995-03-31  0:00     ` Kent Mitchell
1995-03-23  2:08 ` T. Owen O'Malley
1995-03-24 11:44   ` Robert Dewar
1995-03-27 14:01     ` Theodore Dennison
1995-03-29  0:00       ` John DiCamillo
1995-03-30  0:00         ` Theodore Dennison
1995-03-30  0:00         ` Robb Nebbe
1995-03-30  0:00       ` Henry Baker
1995-04-04  0:00         ` John Baker
1995-04-05  0:00           ` Tucker Taft
1995-04-06  0:00             ` Norman H. Cohen
1995-04-07  0:00               ` Tucker Taft
1995-04-05  0:00           ` Pat Rogers
1995-04-05  0:00           ` Sverre Brubaek
1995-04-05  0:00           ` Ray Toal
1995-03-30  0:00   ` Robert I. Eachus
1995-03-23 22:38 ` Tucker Taft
1995-03-24  1:57 ` Henry Baker
1995-03-24 17:30   ` Larry Kilgallen, LJK Software
1995-03-26  0:00     ` Henry Baker
1995-03-27 15:19     ` Norman H. Cohen
1995-03-27 14:35   ` Kennel
1995-03-24 12:29 ` Mike Meier [this message]
1995-03-24 10:46   ` Fred J. McCall
1995-03-24 15:44   ` David Weller
1995-03-25  1:55   ` kkrieser
  -- strict thread matches above, loose matches on Subject: below --
1995-03-27  9:36 Duncan Sands
replies disabled

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