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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,147f221051e5a63d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!news.glorb.com!wn14feed!worldnet.att.net!bgtnsc04-news.ops.worldnet.att.net.POSTED!53ab2750!not-for-mail Newsgroups: comp.lang.ada From: anon@anon.org (anon) Subject: Re: memory management in Ada: tedious without GC? Reply-To: anon@anon.org (anon) References: <4ddef8bf-b5b1-4d7e-b75b-386cd6c8402c@l17g2000pri.googlegroups.com> X-Newsreader: IBM NewsReader/2 2.0 Message-ID: Date: Fri, 16 May 2008 22:45:00 GMT NNTP-Posting-Host: 12.64.12.102 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc04-news.ops.worldnet.att.net 1210977900 12.64.12.102 (Fri, 16 May 2008 22:45:00 GMT) NNTP-Posting-Date: Fri, 16 May 2008 22:45:00 GMT Organization: AT&T Worldnet Xref: g2news1.google.com comp.lang.ada:126 Date: 2008-05-16T22:45:00+00:00 List-Id: Ada is design for creating a hard optimized Ada partition (program) that uses no GC. In a true optimized partition the "New" function should be only used in the initialization stage and the "Deallocation" (free) function during the finalization stage. In this design the programmer can create their own memory management package that is needed by the partition which can be optimized to fit the needs of the execution of that partition. This way the partition does not have to wait for memory resources from the OS or other programs. The exception is memory page swapping which can be controlled by the partition in some cases. As for being error-prone, the answer is no. The partition request all of the needed memory before it continues with the execution. In this way the Ada run-time system knows that it has the memory necessary for the execution of the partition . It might seam to be wasteful, but a hard optimized partition only waste a small amount of memory. The unused part of the allocated memory block. Also, forget "C++ like" design structure it design from "C". Ada and most other compilers are written using the C libraries structures not "C++ like". But for some reason a lot of "C++" programmers are trying to alter the facts and saying "C++" instead of C. Also, the Java low-level routines are written in C as well. In <4ddef8bf-b5b1-4d7e-b75b-386cd6c8402c@l17g2000pri.googlegroups.com>, "jhc0033@gmail.com" writes: >I'm mostly soliciting answers from Ada programmers who know C++ RAII >well (Skip this if you use the words "C" and "C++" interchangeably, >please. Your answers will be misleading at best): > >As I understood from reading the Memory Management section of >Wikibooks on Ada, Ada's memory management facilities are roughly >equivalent to > >a. C++-like "new" >b. C++-like "delete" >c. Java-like "finally" >d. your implementation may or may not have GC > >Did I misunderstand? > >To me, this seems much, much more error-prone and tedious that C++'s >RAII approach, where you almost never have to worry about deallocation >(i.e. "b" and "c" above), even in the presence of exceptions, unless >you have GC. Besides, RAII applies to a bunch of other things, like >thread locks, database connections, files - not just memory.