Right, but as a programmer you rarely have control over that. And even if you do, you often can't handle out of memory errors gracefully.
Thus, for a typical situation it is reasonable to log the error and bail out, rather than adding extra custom error handling around every single memory allocation, which ends up being code that is never tested.
It is pointless, because in Linux all you get is a virtual address. Physical backing is only allocated on first use.
In other words, the first time you access a "freshly allocated" non-null pointer you may get a page fault due to insufficient physical memory.
By default, yes. You can configure it to not overcommit
Right, but as a programmer you rarely have control over that. And even if you do, you often can't handle out of memory errors gracefully.
Thus, for a typical situation it is reasonable to log the error and bail out, rather than adding extra custom error handling around every single memory allocation, which ends up being code that is never tested.