News for hackers. Stuff that matters.
Re:Once upon a time, memory allocators made sense by merijnv on Monday January 18, 2016 @07:49AM (#10924072)
> (a) malloc() never returns NULL. It always returns a valid address, even though your system may have out of memory.

This is only true on Linux, for example, FreeBSD by default has partial overcommit and WILL start returning null after overcommitting some percentage of memory (I think 30% or so by default)

Re:Once upon a time, memory allocators made sense by ekimekim on Monday January 18, 2016 @10:28AM (#10924879)
Most major linux distros default to "heuristic overcommit", aka vm.overcommit_memory=0. The intent being to refuse obviously excessive allocations without sticking to a strict limit.

You can also enable behaviour like you describe by setting overcommit_memory=2 and some ratio overcommit_ratio (default 50) or exact number of kbytes overcommit_kbytes

Source: https://www.kernel.org/doc/Documentation/vm/overcommit-accou... https://www.kernel.org/doc/Documentation/sysctl/vm.txt