comp.lang.ada
 help / color / mirror / Atom feed
From: Ole-Hjalmar Kristensen <ole-hjalmar.kristensen@substitute_employer_here.com>
Subject: Re: memory management and productivity
Date: 22 Jun 2004 09:58:09 +0200
Date: 2004-06-22T07:58:09+00:00	[thread overview]
Message-ID: <wvbrvfhkqb1q.fsf@sun.com> (raw)
In-Reply-To: L3EBc.15198$z24.12408@nwrdny01.gnilink.net

>>>>> "FJL" == Frank J Lhota <NOSPAM.lhota.adarose@verizon.net> writes:

    FJL> "Ole-Hjalmar Kristensen"
    FJL> <ole-hjalmar.kristensen@substitute_employer_here.com> wrote in message
    FJL> news:wvbrsmcp2uqd.fsf@europa1.Norway.Sun.COM...
    >> > Russ wrote:
    >> Yes, *IF* it has been allocated with new.

    FJL> In C++, all memory allocation / deallocation should be done using the new /
    FJL> delete operators. This is true even for pointers to classes that do not have
    FJL> constructors or destructors. This is because classes often have default
    FJL> constructor / destructor actions that need to be performed for the object to
    FJL> be usable. For example, if the class has any virtual methods, then "jump
    FJL> table" must be set up. Also, if any field / sub-field / sub-sub-field has a
    FJL> constructor / destructor, then this constructor / destructor cannot be
    FJL> ignored.

Yes, I agree. I was thinking about stack-allocated objects, where
the destructor is called automatically for you upon exit of the
varaible's scope.

    FJL> The safe way to change the memory management algorithms for a given C++
    FJL> class is to define new / delete operators for that class. This will permit
    FJL> the user-defined algorithms for allocation / deallocation to be used for the
    FJL> class without interfering with constructor / destructor actions. This is the
    FJL> 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.

    FJL> I agree. It would be more accurate to say that in both Ada and C++, the
    FJL> tools are there to implement your types with GC.

Yes, that would be more accurate, although conservative collectors
like Boehm's would probably work with both languages.

-- 
   C++: The power, elegance and simplicity of a hand grenade.



  reply	other threads:[~2004-06-22  7:58 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-06-17  4:56 memory management and productivity Russ
2004-06-17  5:15 ` tmoran
2004-06-17  8:07 ` Martin Dowie
2004-06-18 23:10   ` Russ
2004-06-19  9:04     ` Martin Dowie
2004-06-21  4:16       ` Russ
2004-06-21  7:29         ` Jano
2004-06-21  8:02           ` Martin Dowie
2004-06-21  8:22             ` Jano
2004-06-21  9:07               ` Martin Dowie
2004-06-21 22:36             ` Brian May
2004-06-22  7:47               ` Martin Dowie
2004-06-21  8:14           ` Ole-Hjalmar Kristensen
2004-06-21  8:27             ` Jano
2004-06-21  8:29             ` Martin Dowie
2004-06-22  7:53               ` Ole-Hjalmar Kristensen
2004-06-26 15:44                 ` Robert I. Eachus
2004-06-21 16:31             ` Frank J. Lhota
2004-06-22  7:58               ` Ole-Hjalmar Kristensen [this message]
2004-06-21  8:14           ` Martin Krischik
2004-06-21 15:22             ` Hyman Rosen
2004-06-21 16:47               ` Martin Krischik
2004-06-21 17:51           ` Hyman Rosen
2004-06-22 17:02             ` Pascal Obry
2004-06-26 15:54             ` Robert I. Eachus
2004-06-21  7:46         ` Martin Dowie
2004-06-21 19:03           ` Russ
2004-06-22  2:39             ` David Starner
2004-06-22  8:03               ` Ole-Hjalmar Kristensen
2004-06-23  4:41                 ` Russ
2004-06-23  7:41                   ` Martin Dowie
2004-06-23 17:36                     ` Björn Persson
2004-06-23 22:06                       ` David Starner
2004-06-24  0:34                         ` Björn Persson
2004-06-24  6:45                           ` Martin Krischik
2004-06-24 10:27                             ` Wes Groleau
2004-06-23 23:02                       ` Russ
2004-06-26 16:16                         ` Robert I. Eachus
2004-06-23 13:11                   ` Larry Kilgallen
2004-06-23 17:21                     ` Björn Persson
2004-06-24  7:35                       ` Ole-Hjalmar Kristensen
2004-06-26 17:10                         ` Simon Wright
2004-06-23 18:18                     ` Russ
2004-06-23 23:18                       ` David Starner
2004-06-23 22:15                     ` Larry Kilgallen
     [not found]                     ` <bebbba07.0406231018.21Organization: LJK Software <IKJODEu6UfVI@eisner.encompasserve.org>
2004-06-24  6:40                       ` Russ
2004-06-26 16:33                         ` Robert I. Eachus
2004-06-29  0:33                           ` Randy Brukardt
2004-06-24 13:29                     ` Stephen Leake
2004-06-24 14:09                       ` Hyman Rosen
2004-06-24 19:58                         ` Frank J. Lhota
2004-06-25  1:30                         ` Stephen Leake
2004-06-25  2:15                         ` Russ
2004-06-24 19:26                       ` Russ
2004-06-25  1:37                         ` Stephen Leake
2004-06-25 10:13                           ` Ole-Hjalmar Kristensen
2004-06-26  0:20                             ` David Starner
2004-06-25 23:35                           ` Russ
2004-06-26 11:27                             ` Martin Dowie
2004-06-26 13:45                             ` Ed Falis
2004-06-26 20:38                               ` Russ
2004-06-26 21:36                                 ` Ludovic Brenta
2004-06-27  7:54                                   ` Dmitry A. Kazakov
2004-06-26 17:20                             ` Robert I. Eachus
2004-06-25  8:52                         ` David Starner
2004-06-24 20:51                     ` Larry Kilgallen
2004-06-22  6:09             ` Martin Krischik
2004-06-22 10:20             ` Georg Bauhaus
2004-06-26 16:00             ` Robert I. Eachus
2004-06-21  8:23         ` Dmitry A. Kazakov
  -- strict thread matches above, loose matches on Subject: below --
2004-06-21 10:33 Christoph Karl Walter Grein
2004-06-21 10:38 ` Jano
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox