[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: A note to exceptions && some notes to codesize
From:       Waldo Bastian <bastian () ens ! ascom ! ch>
Date:       1999-06-11 8:43:52
[Download RAW message or body]

Uwe Thiem wrote:
On Wed, 9 Jun 1999, Johannes Sixt wrote:
> > Have you read the whole story? new never returns NULL because it throws an
> > exception of type bad_alloc if there's not enough memory! So exceptions *ARE*
> > used to report out-of-memory situations and exceptions *MUST* be used to
> > *handle* them!
> 
> Hannes, this means that the whole CHECK_PTR() exercise after a "new"
> is useless?  Grrr.

Yes... It always puzzled me what they where doing there anyway....

The bad thing is that you can't really rely on new throwing an exception
neither, because Linux (prolly other Unices as well) tends to overcommit.
This means that new succeeds but that you will get a segmentation fault
once you actually start to use the memory.

Before you reach this point, your system has most likely been hitting
swap quite dramatically.

So although it is good engeering practice to gracefully handle out of
memory situations, in practice it is kind of useless. 

Cheers,
Waldo
-- 
KDE, A New Millenium, A New Desktop                      http://www.kde.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic