Is "Out of Memory" a recoverable error?

Sean Kelly sean at invisibleduck.org
Tue Dec 2 10:15:54 PST 2008


== Quote from Walter Bright (newshound1 at digitalmars.com)'s article
> I asked this over on stackoverflow.com to see what people using other
> languages have to say, as well as the D community. The reason I ask is
> to see if memory allocation can be allowed in functions marked "nothrow".
> http://stackoverflow.com/questions/333736/is-out-of-memory-a-recoverable-error

Yes, but unlike some exceptions where retrying the same code may
succeed, an out of memory condition almost always requires explicit
handling for recovery.  Because it's not typical for an application to
explicitly handle memory errors however, I think an OOME can
generally be treated as an unrecoverable error.

I suppose it's worth mentioning that the OOME exception class derives
from Error now in D 2.0, for the reasons mentioned above.  Not sure
if you'd simply like to judge recoverability based on the superclass
choice, but it would be a simple enough rule to follow.


Sean



More information about the Digitalmars-d mailing list