You can only react to OOM when the OS gives you the necessary tools - under ordinary OSs malloc will not fail, even if it couldn’t actually allocate - actual allocation only happens when one writes to the location.
But it doesn’t really apply to the topic at hand, just wanted to add.
But it doesn’t really apply to the topic at hand, just wanted to add.