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,aa968038a51ee866 X-Google-Attributes: gid103376,public From: Ron Thompson Subject: Re: Q: Ada.Unchecked_Deallocation Date: 1996/07/12 Message-ID: <4s5j6fINN3pj@faatcrl.faa.gov>#1/1 X-Deja-AN: 167986510 references: <31E5D4D1.11DB36E1@jinx.sckans.edu> content-type: text/plain; charset=us-ascii organization: aos-420 mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 1.2 (Windows; U; 32bit) Date: 1996-07-12T00:00:00+00:00 List-Id: David Morton wrote: >Quick one here... > >If something is created dynamically with new, is it >necessary to deallocate it with Ada.Unchecked_Deallocation, >or will it be removed from the heap space when the program >exits? From the "C" world, I've always been taught to clean >up after myself... is this necessary? It seems that usually, >"Unchecked" anything in Ada is bad... > >Ada95, GNAT on Linux 2.0 > >Thanks! > The scope of any dynamically allocated object is the same as the scope of the largest enclosure. What a mouthful. If the "new" object has a local scope, that is it is declared down here in this particular routine, then it is freed back to OS when this routine closes. Larger scope, say top of the package body, it would behoove the programmer to know whether or not they'll be needin this thing, and deallocate it when they don't. Spec or driver scope will live as long as the enclosure as well, so they should be alloc'd and dealloc'd as needed if memory is a concern. Unchecked deallocation has a much scarier name then free(). But free() really is just unchecked deallocation. The kernel doesn't care WHAT you deallocate, hence unchecked. rct The opinions above are mine and mine alone. Except the scope thing. Thats LRM stuff.