Regarding nothrow and @safe
Jacob Carlborg
doob at me.com
Sun Aug 21 03:38:47 PDT 2011
On 2011-08-21 02:26, Jonathan M Davis wrote:
> On Saturday, August 20, 2011 18:18:25 Sean Eskapp wrote:
>> bearophile:
>>> As far as I know they have decided to make memory overflow errors, so
>>> they are
>> not exceptions, you can't catch them. Other people will confirm this or not.
>>
>> In this case, how would you go about handling out-of-memory situations? A
>> systems programming language should certainly give the programmer the
>> option to deal with this.
>
> The short answer: You don't. It's an incredibly bad idea.
>
> The long answer: You catch Error - or OutOfMemoryError if you want that
> specific one. So, you could try and catch it and handle it, but most of the
> cleanup during the unwinding of the stack gets skipped. scope statements and
> destructors don't get called. Your program is not likely to be in state where
> it makes any real sense to try and continue. You _can_ do it, but it's a bad
> idea.
>
> - Jonathan M Davis
What about if you have an application doing heavy image/video
processing, the application could empty some caches or similar. The
application could still work, just not as fast as with caches.
--
/Jacob Carlborg
More information about the Digitalmars-d-learn
mailing list