Path: utzoo!mnetor!tmsoft!torsqnt!snitor!doug From: doug@snitor.uucp (Doug Moen) Newsgroups: comp.lang.modula3 Subject: running out of memory Message-ID: Date: 8 Feb 91 17:42:23 GMT References: <9102080401.AA29237@jumbo.pa.dec.com> Organization: Siemens Nixdorf Lines: 46 In article <9102080401.AA29237@jumbo.pa.dec.com> gnelson (Greg Nelson) writes: > 2) The NEW expression's behaviour is not defined in the case that > not enough memory is left. Is this a checked runtime error, or > does it return NIL? If it returns NIL, then it isn't returning > a "new" value. If it is a checked runtime error, how do you > allocate all available memory without crashing? > >The report should have defined this to be a checked runtime error. >If you want to allocate all available memory without crashing, you >have to use a lower-level, implementation-dependent interface. I strongly disagree. The report should have defined this to raise an exception. There are many programs for which crashing on memory exhaustion is unacceptable behaviour. Examples include: text editors, shells, window managers, daemons providing essential system services, and just about any interactive program. In order to write any of these programs in Modula-3, it is necessary to: - use a low-level, implementation-dependent interface for allocating memory (which means the program isn't portable) - avoid using any library module that calls NEW. This means avoiding most standard modules, including Text and Thread. These are very serious restrictions, which lead me to believe that Modula-3 is simply not suitable for writing interactive programs or daemons that are required to be robust. The text editor I use is written in C, and does not crash when it runs out of memory or temp file space. Instead, it displays an error message, and permits me to save my changes before exiting. This robustness has saved my bacon on at least one occasion. Last year, I wrote an image editor using Motif & the X Toolkit. This editor has prodigious memory requirements, since the images we deal with can be quite large. The X Toolkit aborts your program if it runs out of memory. As a result, it is possible to crash my editor simply by opening a large number of windows. Of course, when the editor crashes, you lose all of your work. This has actually happened to users of my program. I find this most upsetting, since to fix the bug, I would have to reimplement Motif and the X Toolkit. The preface to the Modula-3 report says: "The goal of Modula-3 is to be as simple and safe as it can be while meeting the needs of modern systems programmers." Modula-3 can't meet these goals until NEW has been redefined to raise an exception on memory exhaustion.