Regarding nothrow and @safe
Jonathan M Davis
jmdavisProg at gmx.com
Thu Aug 25 11:46:07 PDT 2011
On Thursday, August 25, 2011 11:38 Nick Sabalausky wrote:
> "Jacob Carlborg" <doob at me.com> wrote in message
> news:j2qn7n$1db7$1 at digitalmars.com...
>
> > On 2011-08-21 02:26, Jonathan M Davis wrote:
> >> 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.
>
> I remember some discussion awhile back about having some sort of scheme in
> the GC where you could tell the GC "Hey, in low-memory situations, instead
> of bailing out with an Error, call this delegate I'm giving you and I'll
> try to clear out my caches to free up some memory." Unfortunately, I don't
> think anything's actually come out of that so far. I really hope it does
> though, it's a great idea.
Not a bad idea. It would still have to throw an OutOfMemoryError if it really
couldn't free enough memory, but it would still improve the situation for
anyone looking to use caches or anything else which could have its memory
freed and still allow the program to function correctly if the memory
consumption gets too high.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list