From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ed6a891101ff4e06 X-Google-Attributes: gid103376,public From: tmoran@bix.com (Tom Moran) Subject: Re: Freeing Pointers to classwide types Date: 1998/09/28 Message-ID: <360fc072.1728326@SantaClara01.news.InterNex.Net>#1/1 X-Deja-AN: 395690758 References: <1ftmFTC69GA.191@samson.airnet.net> <360b26a1.41575272@SantaClara01.news.InterNex.Net> <6ugeu2$79u$1@nnrp1.dejanews.com> <360c4a70.29707515@SantaClara01.news.InterNex.Net> <6uifpt$e98$1@nnrp1.dejanews.com> <360d1380.165146@SantaClara01.news.InterNex.Net> <6ulj29$ne3$1@nnrp1.dejanews.com> <360e790d.241368@SantaClara01.news.InterNex.Net> <6umkl8$qbm$1@nnrp1.dejanews.com> <360f143c.39974468@SantaClara01.news.InterNex.Net> <6uo8mt$el9$1@nnrp1.dejanews.com> Organization: InterNex Information Services 1-800-595-3333 Newsgroups: comp.lang.ada Date: 1998-09-28T00:00:00+00:00 List-Id: >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?