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, MSGID_RANDY autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,5653f0bd43045b85 X-Google-Attributes: gid103376,public From: Robert Dewar Subject: Re: garbage collection Date: 1999/08/19 Message-ID: <7pi1mv$lc7$1@nnrp1.deja.com>#1/1 X-Deja-AN: 514850329 References: <7pe93j$ehg$1@dailyplanet.wam.umd.edu> <1ZCu3.301$26.56649@typhoon-sf.snfc21.pbi.net> <37BC2203.328E6338@averstar.com> X-Http-Proxy: 1.0 x22.deja.com:80 (Squid/1.1.22) for client 205.232.38.14 Organization: Deja.com - Share what you know. Learn what you don't. X-Article-Creation-Date: Thu Aug 19 22:50:12 1999 GMT X-MyDeja-Info: XMYDJUIDrobert_dewar Newsgroups: comp.lang.ada X-Http-User-Agent: Mozilla/4.04 [en] (OS/2; I) Date: 1999-08-19T00:00:00+00:00 List-Id: In article <37BC2203.328E6338@averstar.com>, Tucker Taft wrote: > Keith Thompson wrote: > > > > tmoran@bix.com writes: > > > > If an implementation doesn't provide garbage collection then that > > > > storage is forever lost, is that correct? > > > > > > No. When the access type goes out of scope there is clearly no way > > > the storage can be on the target end of a pointer, so the > > > implementation should free that storage. > > > > Just to clarify, most implementations don't actually do this. Thus, > > under most Ada implementations, storage *will* be "forever lost" if > > you allocate it and don't explicitly deallocate it. (Well, "forever" > > usually means "until the program terminates".) > > In Ada 95, implementations are required to reclaim the storage associated > with an access type if the 'Storage_Size attribute is specified (which > Tom also mentioned, by the way). If no 'Storage_Size is specified, then > you are correct that most Ada 95 compilers don't reclaim the storage > automatically when leaving the scope of the access type. Ada compilers have differed here. The old Alsys compilers always used to automatically free local access stuff on exit. The trouble is that people are quite used to controlling this memory manually, and in this case you do add quite a bit of overhead by arranging for the automatic release. We went backwards and forwards on what the default should be in GNAT, and decided finally that the default was not to free this storage, however, it is trivial to specify that the space for a local access collection SHOULD be freed on access by using: for access_type_name'Storage_Pool use System.Pool_Local.Unbounded_Reclaim_Pool; Probably a good idea would be to add a configuration pragma that made this pool assignment the default. By the way, a recommendation is to look through the collection of storage pool implementations provided in GNAT, there is a lot of useful functionality there, including a very useful debug pool that checks for correct storage handling. P.S. Ada 83 also required that access types with an explicit storage size be freed on scope exit. The Ada 83 RM strongly suggests that this should be the default for all access types, but stops short of requiring this. Even the implication is removed from the Ada 95 RM. Robert Dewar Ada Core Technologies Sent via Deja.com http://www.deja.com/ Share what you know. Learn what you don't.