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.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b99897135d6631cc X-Google-Attributes: gid103376,public Path: g2news1.google.com!news1.google.com!news.glorb.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!gnilink.net!nwrdny01.gnilink.net.POSTED!0f19ed38!not-for-mail From: "Frank J. Lhota" Newsgroups: comp.lang.ada References: <40d15023$1_1@baen1673807.greenlnk.net> <2jnh22F12nvieU2@uni-berlin.de> Subject: Re: memory management and productivity X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1409 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1409 Message-ID: Date: Mon, 21 Jun 2004 16:31:39 GMT NNTP-Posting-Host: 141.154.58.140 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny01.gnilink.net 1087835499 141.154.58.140 (Mon, 21 Jun 2004 12:31:39 EDT) NNTP-Posting-Date: Mon, 21 Jun 2004 12:31:39 EDT Xref: g2news1.google.com comp.lang.ada:1744 Date: 2004-06-21T16:31:39+00:00 List-Id: "Ole-Hjalmar Kristensen" wrote in message news:wvbrsmcp2uqd.fsf@europa1.Norway.Sun.COM... > > Russ wrote: > Yes, *IF* it has been allocated with new. In C++, all memory allocation / deallocation should be done using the new / delete operators. This is true even for pointers to classes that do not have constructors or destructors. This is because classes often have default constructor / destructor actions that need to be performed for the object to be usable. For example, if the class has any virtual methods, then "jump table" must be set up. Also, if any field / sub-field / sub-sub-field has a constructor / destructor, then this constructor / destructor cannot be ignored. The safe way to change the memory management algorithms for a given C++ class is to define new / delete operators for that class. This will permit the user-defined algorithms for allocation / deallocation to be used for the class without interfering with constructor / destructor actions. This is the C++ equivalent of the Ada "for Name'Storage_Pool use ...;" clause. > This is exactly the same as C++. I would say that Ada and C++ are > more or less on equal footing when it comes to garbage collection in > practice. I agree. It would be more accurate to say that in both Ada and C++, the tools are there to implement your types with GC.