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=-2.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,ab4f67f984ef04f9 X-Google-Attributes: gid103376,public Path: controlnews3.google.com!news1.google.com!news.glorb.com!news.cs.univ-paris8.fr!ciril.fr!nnx.oleane.net!oleane!freenix!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Duncan Sands Newsgroups: comp.lang.ada Subject: Re: Is the Ada run-time required to detect out-of-memory conditions? Date: Sat, 22 May 2004 15:40:35 +0200 Organization: Cuivre, Argent, Or Message-ID: References: <878yfmiuak.fsf@insalien.org> <2h7b84Fa2aefU1@uni-berlin.de> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Trace: melchior.cuivre.fr.eu.org 1085233247 19483 212.85.156.195 (22 May 2004 13:40:47 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Sat, 22 May 2004 13:40:47 +0000 (UTC) To: user@domain.invalid, comp.lang.ada@ada-france.org Return-Path: User-Agent: KMail/1.5.4 In-Reply-To: <2h7b84Fa2aefU1@uni-berlin.de> Content-Disposition: inline X-Virus-Scanned: by amavisd-new-20030616-p7 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: controlnews3.google.com comp.lang.ada:774 Date: 2004-05-22T15:40:35+02:00 > 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.