4 ms·
In the old days, if the system couldn't satisfy a memory allocation request, the malloc function in the C library would return NULL and the application would re
by gradschool 5y ago
In the old days, if the system couldn't satisfy a memory allocation
request, the malloc function in the C library would return NULL and
the application would respond accordingly. These days, if the system
can't satisfy a memory request, it perversely returns a pointer to
nowhere in the hope that the application won't try to use it. There's
no portable way for an application to distinguish between usable and
unusable pointers, and even if there were, the system could decide
later that it has given away too much memory and therefore must
repossess it by killing applications at random. (Don't get me started
on "memory safety" in languages that ignore finiteness of the heap.)
Yes, I know it's possible to configure a kernel like the old days, but
then it better be on a dedicated server because otherwise desktop
applications that have come to rely on this behavior would get flaky.