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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,345a8b767542016e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-16 02:07:33 PST Path: archiver1.google.com!postnews1.google.com!not-for-mail From: kcline@optelnow.net (Kevin Cline) Newsgroups: comp.lang.ada Subject: Re: memory leakages with Ada? Date: 16 Mar 2002 02:07:32 -0800 Organization: http://groups.google.com/ Message-ID: References: <3c90af1e@news.starhub.net.sg> <3C923755.7050007@mail.com> NNTP-Posting-Host: 24.219.81.150 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Trace: posting.google.com 1016273252 15905 127.0.0.1 (16 Mar 2002 10:07:32 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 16 Mar 2002 10:07:32 GMT Xref: archiver1.google.com comp.lang.ada:21325 Date: 2002-03-16T10:07:32+00:00 List-Id: Hyman Rosen wrote in message news:<3C923755.7050007@mail.com>... > Kevin Cline wrote: > > No problem in C++ though: > > nbBytes = GetNbBytes( dataSource ); > > std::vector data(nbBytes); > > GetData( data ); > > But this is identical in spirit to the C version, > in that memory will be allocated from the heap > instead of the stack. The Ada version requires > no deallocation or destruction other than that > afforded by exiting the scope of the object. It's not at all like the C version. The memory is managed by std::vector, and will be deallocated in the vector destructor when the scope is exited. In a well-written C++ (or Ada) program all memory allocation and deallocation will be handled by low-level classes. Explicit calls to allocate or deallocate memory should never appear in higher-level code.