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,13d6cd0af0d0d769 X-Google-Attributes: gid103376,public From: RTOAL@lmumail.lmu.edu (Ray Toal) Subject: Re: Does memory leak? Date: 1995/04/05 Message-ID: #1/1 X-Deja-AN: 100939418 references: <3kopao$ekg@nef.ens.fr> <3kql6c$1b3@porte-de-st-ouen.ics.uci.edu> <3kuba0$8kd@gnat.cs.nyu.edu> <3l6gf6$h05@theopolis.orl.mmc.com> <3ls2ku$qls@hacgate2.hac.com> organization: Loyola Marymount University newsgroups: comp.lang.ada Date: 1995-04-05T00:00:00+00:00 List-Id: In article <3ls2ku$qls@hacgate2.hac.com> jbaker@thor.tu.hac.com (John Baker) writes: >Henry Baker (hbaker@netcom.com) wrote: >: In article <3l6gf6$h05@theopolis.orl.mmc.com>, Theodore Dennison >: wrote: >: > Perhaps I'm missing something here...what exactly is wrong with using >: > UNCHECKED_DEALLOCATION? >: > >: > I mean, if you don't deallocate what you allocate, your program will >: > leak memory no matter what language it is written in. This isn't an Ada >: > issue, it's an issue of sloppy coding. >: Not necessarily true. I've written lots and lots of Lisp programs, and >: I think that I forgot to deallocate in almost all of them. They worked >: just fine. >: (Of course I'm being facetious. Lisp doesn't have a deallocate primitive, >: because it has an automatic garbage collector, just like Modula and Eiffel. >: Furthermore, garbage collection can't collect stuff that is still linked >: to live objects, so you can still get a 'leak' this way.) >The Lisp i programmed in (symbolics) had a really nice feature -- >allocation to *named* areas of memory. You could allocate >objects with differing life spans in different areas and then >(at the appropriate time), wipe a whole named area and start over >without having to destroy the objects individually. Very fast >and easy to control. I'd like to see a feature like that in C++ >and ADA. >JB Certainly they exist, but you have to write them yourself. In C++ you can overload the 'new' operator to allocate to your own arenas. Ada suggests that implementations manage the "heap" as a collection of pools that "belong to" specific access types; since this is only implementation advice you may have to simulate this yourself if your compiler supports neither automatic garbage collection or pools. You can in any modern language define a particular array to use for allocation of certain objects and write an allocation procedure. In fact, it is a good idea because a memory pool in which all objects are of the same size is not subject to fragmentation and allocation/ deallocation is O(1). Ray Toal