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:15:19 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:15:19 -0800 Organization: http://groups.google.com/ Message-ID: References: <3c90af1e@news.starhub.net.sg> <3C9238A5.7060700@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 1016273719 16095 127.0.0.1 (16 Mar 2002 10:15:19 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: 16 Mar 2002 10:15:19 GMT Xref: archiver1.google.com comp.lang.ada:21326 Date: 2002-03-16T10:15:19+00:00 List-Id: Hyman Rosen wrote in message news:<3C9238A5.7060700@mail.com>... > Kevin Cline wrote: > > So dynamic memory allocation is no problem in Ada because "we just don't > > do that?" That's fine for embedded applications, but the users of desktop > > applications expect them to consume memory proprotional to the data > > set size. They aren't too happy with messages like "sorry, file too large, > > please increase DATA_FILE.MAX_SIZE and recompile." > > That's not what he said. In Ada you can declare arrays whose size > depends on expressions evaluated at runtime, whereas in C89/C++ > (but not C99) array sizes must be constant expressions. Therefore > situations which call for buffers whose size depends on some > external value can be handled cleanly in Ada by just reading that > external value and using it to declare an array whose size depends > on it. A halfway-decent C++ programmer would never use an dynamically allocated array for this purpose. He would use std::vector or std::string. Internally this will result in a heap allocation and deallocation, but that's no problem unless you're stuck with a pathologically bad allocator. > If you actually need to store these variably-sized objects > then of course you will need dynamic allocation... Exactly my point, together with the observation that a great many applications do have this need.