comp.lang.ada
 help / color / mirror / Atom feed
From: tmoran@bix.com (Tom Moran)
Subject: Re: Freeing Pointers to classwide types
Date: 1998/09/28
Date: 1998-09-28T00:00:00+00:00	[thread overview]
Message-ID: <360fc072.1728326@SantaClara01.news.InterNex.Net> (raw)
In-Reply-To: 6uo8mt$el9$1@nnrp1.dejanews.com

>The whole point of a
>user storage pool is that the user defines what is to be done!
My understanding of the RM is that a user decides how the Allocate and
Deallocate procedures for his storage pool will work.  The question at
issue, however, is when Deallocate is to be called.  How does the user
specify this?
  If the user specifies a private storage pool inside the procedure,
eg
      procedure Something is
         My_Pool : My_Pool_Type(5000);
then, hopefully(is this required?), the compiler will release the
storage of My_Pool on scope exit, thus effectively releasing the
memory of any access types going out of scope that are associated with
My_Pool.  Is that the only way to prevent the storage leak?  It
certainly seems to me that having a bunch of small storage pools in a
program, instead of one large shared heap, obviates one of the reasons
for using heap storage as opposed to simply declaring, say, a
plenty-large array of elements of the relevant type and using inexing
instead of access types.
  I tested the original code I posted in this thread to see what Gnat
3.11 does on exiting the scope of an access type.  The answer is that
multiple calls to the procedure will result in a Storage Error.  The
gnat-rm.txt file says to look in s-gnapoo (which I don't have handy)
for what is presumably a vendor-supplied-library storage pool.  Is
that what you mean by how trivial it is to use storage pools in Gnat?
Without this, the user would have to write his own Allocate and
Deallocate, which, frankly, I would hope, but not expect, all
programmers to do well. 
   So it appears to me the bottom line is:If you want to release the
memory on procedure exit, you will have to do stack-like, rather than
heap-like allocation of an instance of a special storage pool.  Your
compiler vendor may, or may not, offer helpful, well written, storage
pool routines as part of his vendor-supplied-library.  Am I mistaken?




  reply	other threads:[~1998-09-28  0:00 UTC|newest]

Thread overview: 61+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-09-24  0:00 Freeing Pointers to classwide types joecool
1998-09-25  0:00 ` Tom Moran
1998-09-25  0:00   ` Bob Fletcher
1998-09-25  0:00     ` Samuel Tardieu
1998-09-25  0:00     ` dennison
1998-10-09  0:00     ` Matthew Heaney
1998-10-12  0:00       ` Mats Weber
1998-10-12  0:00         ` Pat Rogers
1998-09-25  0:00   ` dewarr
1998-09-25  0:00     ` Tom Moran
1998-09-25  0:00       ` dewarr
1998-09-26  0:00     ` Tom Moran
1998-09-26  0:00       ` dewarr
1998-09-26  0:00         ` Tom Moran
1998-09-27  0:00           ` dewarr
1998-09-27  0:00             ` Tom Moran
1998-09-28  0:00               ` dewarr
1998-09-28  0:00                 ` Tom Moran
1998-09-28  0:00                   ` dewarr
1998-09-28  0:00                     ` Richard D Riehle
1998-09-28  0:00                       ` Pat Rogers
1998-09-29  0:00                       ` dewarr
1998-09-28  0:00                   ` dewarr
1998-09-28  0:00                     ` Tom Moran [this message]
1998-09-28  0:00                       ` Tom Moran
1998-09-28  0:00                         ` Brian Rogoff
1998-09-28  0:00                       ` Pat Rogers
1998-09-28  0:00                         ` Tom Moran
1998-09-28  0:00                           ` Pat Rogers
1998-09-29  0:00                           ` dewarr
1998-09-29  0:00                             ` Tom Moran
1998-09-30  0:00                               ` Tom Moran
1998-10-01  0:00                                 ` dewar
1998-10-01  0:00                                   ` Tom Moran
1998-10-01  0:00                                     ` dewarr
1998-10-01  0:00                                       ` Tom Moran
1998-10-01  0:00                                     ` dewarr
1998-10-01  0:00                                     ` Samuel Tardieu
1998-10-01  0:00                                       ` Tom Moran
1998-10-01  0:00                                         ` Tucker Taft
1998-10-01  0:00                                           ` Tom Moran
1998-10-02  0:00                                           ` dewarr
1998-10-02  0:00                                             ` Larry Kilgallen
1998-10-02  0:00                                               ` dewarr
1998-10-02  0:00                                           ` dennison
1998-10-02  0:00                                             ` dewarr
1998-10-01  0:00                                         ` dennison
1998-10-02  0:00                                         ` dewarr
1998-10-09  0:00                                           ` Matthew Heaney
1998-10-09  0:00                                             ` dennison
1998-10-09  0:00                                               ` Matthew Heaney
1998-10-09  0:00           ` Matthew Heaney
1998-10-09  0:00   ` Matthew Heaney
1998-09-25  0:00 ` alan walkington
1998-09-26  0:00 ` Simon Wright
1998-10-09  0:00 ` Matthew Heaney
1998-10-09  0:00   ` Niklas Holsti
1998-10-10  0:00     ` Matthew Heaney
1998-10-11  0:00       ` Niklas Holsti
1998-10-11  0:00         ` Matthew Heaney
  -- strict thread matches above, loose matches on Subject: below --
1998-09-25  0:00 bpr5549
replies disabled

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