From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: memory management in Ada: tedious without GC?
Date: Mon, 19 May 2008 14:21:56 -0700 (PDT)
Date: 2008-05-19T14:21:56-07:00 [thread overview]
Message-ID: <8d288545-e0c6-4f70-b3d5-3d037ab0bff2@y21g2000hsf.googlegroups.com> (raw)
In-Reply-To: b0bb8ae7-881b-4605-b20c-faa3a2f88a91@j22g2000hsf.googlegroups.com
On 19 Maj, 17:37, Matthew Heaney <mhea...@on2.com> wrote:
> > 1. No support for exception-safe assignment in Ada.
>
> It depends on how you define "exception-safe".
I meant strong safety (either all OK or nothing modified).
> Assignment in Ada
> makes only a "basic guarantee" wrt exception safety
Yes.
> (State is not preserved
> because finalization of the LHS happens before the assignment proper.)
Note also that it prevents some obvious optimizations like avoiding
memory allocator round-trip when for example short container is
assigned to a longer one, which already has enough place for RHS.
> > 2. Memory leak after exception is raised while initializing the
> > allocated object in Ada.
>
> If by "initializing" you mean invoking a controlled action
I meant initialization of components like here:
type T is record
X : Integer := Initialize_Me;
end record;
It can be any exception other than Program_Error, including user-
defined one.
> I do forget the exact rules about memory reclaimation, though;
> if I do
> this:
>
> declare
> P : T_Access := new T;
> begin
>
> and the initialization of the object designed by P fails (e.g. because
> controlled initialization fails, which raises Program_Error, or
> because component initialization fails, which raises
> Constraint_Error), then what does the language say about reclaiming
> the memory allocated for P.all?
The memory is lost.
OK, it is still managed by the relevant storage pool - but if the pool
itself is not dynamically scoped (or the scope is just too wide), then
it is effectively a leak.
--
Maciej Sobczak * www.msobczak.com * www.inspirel.com
next prev parent reply other threads:[~2008-05-19 21:21 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-16 17:44 memory management in Ada: tedious without GC? jhc0033
2008-05-16 18:56 ` Ludovic Brenta
2008-05-16 20:42 ` Maciej Sobczak
2008-05-16 21:45 ` Ivan Levashew
2008-05-16 22:59 ` Peter C. Chapin
2008-05-17 5:24 ` jhc0033
2008-05-17 7:50 ` Ivan Levashew
2008-05-16 23:05 ` Randy Brukardt
2008-05-19 3:50 ` Matthew Heaney
2008-05-19 7:55 ` Dmitry A. Kazakov
2008-05-19 13:18 ` Georg Bauhaus
2008-05-19 14:16 ` Dmitry A. Kazakov
2008-05-23 23:15 ` Robert A Duff
2008-05-24 0:45 ` Randy Brukardt
2008-05-24 8:25 ` Dmitry A. Kazakov
2008-05-24 16:14 ` Robert A Duff
2008-05-24 19:04 ` Dmitry A. Kazakov
2008-05-24 20:52 ` Robert A Duff
2008-05-25 8:12 ` Dmitry A. Kazakov
2008-05-25 11:28 ` Maciej Sobczak
2008-05-25 12:35 ` Robert A Duff
2008-05-26 8:16 ` Dmitry A. Kazakov
2008-05-24 19:39 ` Georg Bauhaus
2008-05-24 20:45 ` Robert A Duff
2008-05-19 8:35 ` Maciej Sobczak
2008-05-19 15:11 ` Matthew Heaney
2008-05-19 21:13 ` Maciej Sobczak
2008-05-23 23:03 ` Robert A Duff
2008-05-24 0:12 ` Adam Beneschan
2008-05-16 22:45 ` anon
2008-05-17 7:34 ` Pascal Obry
2008-05-17 15:11 ` Bob Klungle
2008-05-17 15:27 ` Pascal Obry
2008-05-17 16:18 ` Georg Bauhaus
2008-05-20 8:04 ` Ole-Hjalmar Kristensen
2008-05-20 8:01 ` Ole-Hjalmar Kristensen
2008-05-20 10:03 ` Martin Krischik
2008-05-17 17:23 ` Martin Krischik
2008-05-17 16:51 ` Maciej Sobczak
2008-05-17 17:45 ` Pascal Obry
2008-05-17 22:28 ` Samuel Tardieu
2008-05-18 7:03 ` Martin Krischik
2008-05-18 8:50 ` jhc0033
2008-05-18 9:31 ` Dmitry A. Kazakov
2008-05-18 14:10 ` Maciej Sobczak
2008-05-18 14:59 ` Dmitry A. Kazakov
2008-05-18 20:51 ` Maciej Sobczak
2008-05-19 8:36 ` Dmitry A. Kazakov
2008-05-18 15:03 ` Martin Krischik
2008-05-18 18:27 ` jhc0033
2008-05-19 4:12 ` Matthew Heaney
2008-05-19 8:39 ` Maciej Sobczak
2008-05-19 15:37 ` Matthew Heaney
2008-05-19 21:21 ` Maciej Sobczak [this message]
2008-05-19 23:02 ` Matthew Heaney
2008-05-19 10:27 ` Martin Krischik
2008-05-17 22:42 ` Peter C. Chapin
2008-05-18 6:58 ` Martin Krischik
2008-05-18 6:52 ` Martin Krischik
2008-05-18 14:16 ` Maciej Sobczak
2008-05-17 14:30 ` Brian Drummond
2008-05-17 16:47 ` Maciej Sobczak
2008-05-19 14:45 ` Brian Drummond
2008-05-20 7:42 ` Maciej Sobczak
2008-05-20 18:01 ` jayessay
2008-05-18 8:06 ` Simon Wright
2008-05-18 14:21 ` Maciej Sobczak
2008-05-18 20:48 ` Simon Wright
2008-05-19 14:40 ` Brian Drummond
2008-05-19 3:44 ` Matthew Heaney
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox