comp.lang.ada
 help / color / mirror / Atom feed
From: Duncan Sands <baldrick@free.fr>
To: user@domain.invalid, comp.lang.ada@ada-france.org
Subject: Re: Is the Ada run-time required to detect out-of-memory conditions?
Date: Sat, 22 May 2004 15:40:35 +0200
Date: 2004-05-22T15:40:35+02:00	[thread overview]
Message-ID: <mailman.8.1085233246.401.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <2h7b84Fa2aefU1@uni-berlin.de>

> I'm very new to Ada, but I'm impressed of all the features. In parallel
> I'm developing a little library to make C programming easier. In this
> library I malloc'ed some "emergency memory" at the program start which
> is simply freed when the process gets out of memory. Then the error
> handler can at least raise an exception or print some warning.

This will not work on some operating systems (such as linux).  They don't
actually allocate the memory until you access it (in particular this means
that malloc never fails).  So you would (at least) need to fill the memory
with something after allocating it, to be sure you were really assigned some
memory.  But even so, the memory is liable to be swapped out to disk after
a while (because the OS will notice that you are not using it).  So freeing it
won't in fact give you any more memory, because that memory area is probably
already being used for something else.  And if the OOM killer (linux specific)
decides to kill you, then your program is instantly dead and you will have no
chance of freeing memory, or doing anything else for that matter.

Ciao,

Duncan.



  parent reply	other threads:[~2004-05-22 13:40 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-20 22:54 Is the Ada run-time required to detect out-of-memory conditions? Ludovic Brenta
2004-05-21  0:44 ` Georg Bauhaus
2004-05-21  0:47 ` Stephen Leake
2004-05-21  0:54   ` Georg Bauhaus
2004-05-21  1:00     ` Stephen Leake
2004-05-21  3:29 ` Robert I. Eachus
2004-05-21  8:04 ` Vinzent 'Gadget' Hoefler
2004-05-21  9:34   ` Martin Krischik
2004-05-21 11:13 ` Wojtek Narczynski
2004-05-21 12:55   ` Martin Krischik
2004-05-21 16:00     ` Robert I. Eachus
2004-05-21 17:13       ` Ludovic Brenta
2004-05-21 23:41         ` Wojtek Narczynski
2004-05-23  8:20       ` Martin Krischik
2004-05-21 19:58   ` Randy Brukardt
2004-05-21 16:56 ` Mark H Johnson
2004-05-21 17:19   ` Ludovic Brenta
2004-05-21 21:39 ` user
2004-05-21 22:04   ` Ludovic Brenta
2004-05-21 22:11     ` Ludovic Brenta
2004-05-22 11:40       ` Simon Wright
2004-05-25 20:43     ` Is the Ada run-time required to detect out-of-memory Robert I. Eachus
2004-05-25 20:58       ` Duncan Sands
2004-05-25 21:19       ` Ludovic Brenta
2004-05-25 21:31         ` Duncan Sands
2004-05-26  7:09       ` Martin Krischik
2004-05-26  7:38         ` Duncan Sands
2004-05-26  8:16           ` Martin Krischik
2004-05-26  8:34             ` Duncan Sands
2004-05-26 16:20               ` Martin Krischik
2004-05-22 13:40   ` Duncan Sands [this message]
2004-05-22 14:09     ` Is the Ada run-time required to detect out-of-memory conditions? Martin Krischik
replies disabled

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