Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!convex!egsner!vector!jonb From: jonb@vector.Dallas.TX.US (Jon Buller) Newsgroups: comp.lang.modula3 Subject: Re: NEW out of memory Message-ID: <1155@vector.Dallas.TX.US> Date: 14 Feb 91 18:55:44 GMT References: <91Feb14.074224pst.16323@alpha.xerox.com> Reply-To: jonb@vector.Dallas.TX.US (Jon Buller) Organization: Dallas Semiconductor Lines: 23 This situation has been known to occur often on 128K Macs (sometimes on larger ones too 8-). What is usually done there, is to pre-allocate a block of memory (10KB seems good for many apps, adjust to taste). When New fails, deallocate the block, clean up, and shut down (or, let the user close some files, windows, and what-have-you, and keep running). If this is done, an exception from New is about the best thing I would want to happen, since I can go into my rainy-day store of memory when I get the exception, and quit. Or, if I'm careful, clean up memory, re-allocate my emergency memory block, and keep going. In any case, I like getting exceptions better than simply getting NIL, or getting my program killed and losing everything. I can handle getting NIL back, but I would probably just use My_New which calls New, and raises an exception if it failed. I once had to write code that checked each allocation, and jumped out of 5 or so procedure calls to return to a main loop on failure, and try to recover. It was in a Pascal without inter-block goto's, so I had to resort to large if-then's in every procedure. The result was MUCH more difficult to read, debug, and look at. I wish I had this kind of stuff back then... -- Jon Buller jonb@vector.dallas.tx.us ..!texsun!vector!jonb FROM Fortune IMPORT Quote; FROM Lawyers IMPORT Disclaimer;