On 1/4/2005 at 12:13 Sandy Ganz wrote:

>What OS does not return NULL or an exception when malloc() fails or is
out
>of memory?

OS/2.   Linux kernels < 2.6.  I think Windows does this too, but I'm
not sure.   

Its harder than you might think to implement, because most OSes don't
allocate memory until you WRITE to it.   There are programs that take
advantage of this by mallocing lots of memory, but only using a small
amount.  Think of large sparse arrays, you allocate a lot of memory,
but only use a few bytes scattered over it.  In order to implement
malloc that fails the system needs to refuse to give you memory, even
though it knows about unused memory (that some other process has
reserved but not touched yet).

Of course when malloc does not fail there are a host of other problems,
eventually the OS just stops your process.   

Reply via email to